Guest User

Untitled

a guest
Jul 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. private static string CACHE_PBP_BABU_KEY = "PBP_BaBus";
  2. private static ICacheManager cache = CacheFactory.GetCacheManager();
  3.  
  4. public IList allBabus {
  5.             get
  6.             {
  7.                 if (!cache.Contains(CACHE_PBP_BABU_KEY) || cache[CACHE_PBP_BABU_KEY] == null)
  8.                 {
  9.                     RefreshComponentsListInCache();
  10.                 }
  11.  
  12.                 return (IList)cache[CACHE_PBP_BABU_KEY];
  13.  
  14.             }
  15.             set
  16.             {
  17.                 // Set is only used to clear the cache!
  18.                 cache.Remove(CACHE_PBP_BABU_KEY);
  19.             }
  20.         }
  21.  
  22.         public void RefreshComponentsListInCache()
  23.         {
  24.             // Get list from DB and store in cache
  25.             cache.Add(CACHE_PBP_BABU_KEY, GetComponents(), CacheItemPriority.Low, null, new AbsoluteTime(TimeSpan.FromMinutes(GenericConfiguration.CacheExpirationMinutes)));
  26.         }
  27.  
  28.         private IList GetComponents()
  29.         {
  30.             // Get everything from database and map it to lightobjects
  31.             IList test = OrganisationManager.GetAllBaBus();
  32.             return Mapper.Map<IList, IList>(test);
  33.         }
Add Comment
Please, Sign In to add comment