/// This is the object to use to cache low volitality data
///
///
///
///
///
public sealed class ApplicationCache
{
///
/// Empty private constructor
/// Static holder types should not have constructors
///
///
private ApplicationCache()
{
}
///
/// Use this to add to the cache
///
/// This is the key for the value to add to the cache
/// This is the value to add to the cache
public static void Add(string key, object value)
{
try
{
CacheManager myManager = CacheFactory.GetCacheManager();
if (!myManager.Contains(key))
myManager.Add(key, value);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// Use this to retreive from the cache
///
/// This is the key for the value to retrieve from the cache
///
public static object GetData(string key)
{
try
{
CacheManager myManager = CacheFactory.GetCacheManager();
return myManager.GetData(key); ;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// Use this to remove items from the cache
///
/// This is the key for the value to remove from the cache
///
public static void RemoveData(string key)
{
try
{
CacheManager myManager = CacheFactory.GetCacheManager();
myManager.Remove(key);
}
catch (Exception ex)
{
throw ex;
}
}
///
/// Use this to query from the cache for a key/value pair
///
/// This is the key for the value to retrieve from the cache
///
public static bool Contains(string key)
{
try
{
CacheManager myManager = CacheFactory.GetCacheManager();
return myManager.Contains(key);
}
catch (Exception ex)
{
throw ex;
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!ApplicationCache.Contains("User_Departments"))
{
// Go to databse and get the object.
ApplicationCache.Add("User_Departments", _departments);
}
return (DepartmentList)ApplicationCache.GetData("User_Departments");