///
/// 设置某缓存的值。
///
/// 缓存的键
/// 缓存的值
public static void SetCache(string CacheKey, object objObject)
{
Cache objCache = HttpRuntime.Cache;
objCache.Insert(CacheKey, objObject);
}
///
/// 取得某缓存的值
///
/// 缓存的键
/// 缓存的值
public static object GetCache(string CacheKey)
{
Cache objCache = HttpRuntime.Cache;
return objCache[CacheKey];
}
-------------------------------------------创建缓存-------------------------------------------
public static object CreateObject(string path, string CacheKey)
{
//从缓存读取
object objType = DataCache.GetCache(CacheKey);
//如果读取为空
if (objType == null)
{
try
{
//反射创建
objType = Assembly.Load(path).CreateInstance(CacheKey);
// 写入缓存
DataCache.SetCache(CacheKey, objType);
}
catch{ }
}
return objType;
}