首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

cache能跨站共享吗解决思路

2011-12-28 
cache能跨站共享吗同个iis内的不同站点能跨站共享吗?[解决办法]关注.帮顶.[解决办法]cache是应用程序的cac

cache能跨站共享吗
同个iis内的不同站点能跨站共享吗?



[解决办法]
关注.帮顶.
[解决办法]
cache是应用程序的cache,所以不能跨应用程序使用
[解决办法]
可以采用依赖文件的方式(多个web程序依赖同一个文件作cache),请看下面的参考代码

public override void SetCache( Common.CacheType cacheType, object value )
{
SetPastExpiration( cacheType );

Context.Cache.Insert( cacheType.ToString(), value, GetCacheDependency(cacheType) );
}

public override void SetPastExpiration( Common.CacheType cacheType )
{
string filePath = GetFilePath( cacheType );

if ( File.Exists(filePath) )
{
lock ( filePath )
{
File.SetLastWriteTime( filePath, DateTime.Now );
}
}
}

热点排行