biu.me

Tag Archives: 代码

.Net缓存应用

因为boss觉得公司的网站访问速度慢,所以这两天把项目加上了缓存,效果很理想,缓存加上瞬间缓存对象就是好几千呐。 接下来的事情就是做好缓存策略的问题,这不下班我发个blog还让编辑叫嚷,说网监让删除的帖子已经删了,但是还显示呢,我的天,删除操作我没更新缓存,只做了Add和Update。干活去了。 ps: memcached  和 squid应用也在计划之中。

很久以前写的解决163相册不允许盗链的代码

public void GetFile(string strFileURL) { string strPhotoRef = strFileURL.Substring(0, strFileURL.IndexOf("/", 8) + 1); //Like: http://img123.photo.163.com/ XMLHTTP _xmlhttp = new XMLHTTPClass(); _xmlhttp.open("GET", strFileURL, false, null, null); _xmlhttp.setRequestHeader("Connection", "Keep-Alive"); _xmlhttp.setRequestHeader("Referer", strPhotoRef); _xmlhttp.send(String.Empty); if(_xmlhttp.readyState == 4) { //Response.ContentType = "image/*"; Response.BinaryWrite((Byte[])_xmlhttp.responseBody); Response.End(); //Response.Redirect(strFileURL); } else { Response.Write("Error!"); } } 现在这样非常消耗服务器资源,如果再加上缓存的思路性能会提升不少。

试用一下wordpress代码显示插件

早就听说 SyntaxHighlighter很牛, 于是找到相关的wordpress插件SyntaxHighlighter Evolved。 我先记录一下插件的使用方法,免得以后忘记了。 引用代码 下面是效果测试。 我使用的引用代码是“【csharp】【/csharp】”,半角。 DataSet ds_unu = (DataSet)Cache["UserNewUpdate_"+ iUserID +""]; if (ds_unu == null) { if (!Photo.BLL.XmlCache.IsCacheExist(strXmlFilePath)) { ds_unu = BLL.ActionLogInfo.GetUserNewUpdateList(iUserID, 15); if (!System.IO.Directory.Exists(strXmlFolderPath)) System.IO.Directory.CreateDirectory(strXmlFolderPath); if (ds_unu.Tables[0].Rows.Count > 0) { Photo.BLL.XmlCache.DataSetToXmlFile(ds_unu, strXmlFilePath); } } else { ds_unu = Photo.BLL.XmlCache.XmlFileToDataSet(strXmlFilePath); if (ds_unu == null || ds_unu.Tables[0].Rows.Count == 0) { ds_unu = BLL.ActionLogInfo.GetUserNewUpdateList_Ds(iUserID, [...]