public class Datacache
{
<summary>
Gets the cache value of the current application specified CacheKey
</summary>
<param name= "CacheKey" ></param>
<returns></returns>
public static Object GetCache (String CacheKey)
{
System.Web.Caching.Cache Objcache = Httpruntime.cache;
return Objcache[cachekey];
}
<summary>
Sets the cache value for the current application to specify CacheKey
</summary>
<param name= "CacheKey" ></param>
<param name= "Objobject" ></param>
public static void Setcache (String CacheKey, Object Objobject)
{
System.Web.Caching.Cache Objcache = Httpruntime.cache;
Objcache.insert (CacheKey, objobject);
}
<summary>
Remove the specified data cache
</summary>
public static void RemoveCache (String CacheKey)
{
System.Web.Caching.Cache Objcache = Httpruntime.cache;
Objcache.remove (CacheKey);
}
<summary>
Clear all caches.
</summary>
public static void Removeallcache ()
{
list<string> Cachekeys = new list<string> ();
IDictionaryEnumerator cacheenum = HttpContext.Current.Cache.GetEnumerator ();
while (Cacheenum.movenext ())
{
Cachekeys.add (CacheEnum.Key.ToString ());
}
foreach (String CacheKey in Cachekeys)
{
HttpContext.Current.Cache.Remove (CacheKey);
}
}
}
class method for C # cache