Filling, Fetching and Removing HttpRuntime.Cache
public static void FillCache(string strCacheKey, object cacheObject)
{
HttpRuntime.Cache.Insert(strCacheKey, cacheObject, null, DateTime.MaxValue, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.NotRemovable, null);
}
public static object GetCache(string cacheKey)
{
object cacheObject = null;
if (HttpRuntime.Cache[cacheKey] != null)
{
cacheObject = HttpRuntime.Cache[cacheKey];
}
return cacheObject;
}
public static bool RemoveCache(string cacheKey)
{
bool isRemoved = false;
if (HttpRuntime.Cache[cacheKey] != null)
{
HttpRuntime.Cache.Remove(cacheKey);
isRemoved = true;
}
return isRemoved;
}
{
HttpRuntime.Cache.Insert(strCacheKey, cacheObject, null, DateTime.MaxValue, TimeSpan.Zero, System.Web.Caching.CacheItemPriority.NotRemovable, null);
}
public static object GetCache(string cacheKey)
{
object cacheObject = null;
if (HttpRuntime.Cache[cacheKey] != null)
{
cacheObject = HttpRuntime.Cache[cacheKey];
}
return cacheObject;
}
public static bool RemoveCache(string cacheKey)
{
bool isRemoved = false;
if (HttpRuntime.Cache[cacheKey] != null)
{
HttpRuntime.Cache.Remove(cacheKey);
isRemoved = true;
}
return isRemoved;
}
Comments
Post a Comment