示例#1
0
 // 15 phút
 public static T GetOrSet <T>(string key, CacheRegion region, System.Func <T> valueFactory, TimeoutMinutes timeoutMinutes = TimeoutMinutes.m15)
 {
     try
     {
         if (!CacheManager.Exists(key, region.ToString()))
         {
             var item = new CacheItem <object>(key, region.ToString(), valueFactory(), ExpirationMode.Absolute, TimeSpan.FromMinutes((int)timeoutMinutes));
             CacheManager.Add(item);
         }
     }
     catch (Exception ex)
     {
         return(default(T));
     }
     return(CacheManager.Get <T>(key, region.ToString()));
 }
示例#2
0
 public static bool Remove(
     string key,
     CacheRegion region
     )
 {
     return(CacheManager.Remove(key, region.ToString()));
 }
示例#3
0
        internal static void Remove(this ICacheService cacheService, CacheRegion region)
        {
            if (cacheService == null)
            {
                throw new ArgumentNullException(nameof(cacheService));
            }

            cacheService.RemoveRegion(region.ToString());
        }
示例#4
0
 public static void Remove(CacheRegion region)
 {
     CacheManager.ClearRegion(region.ToString());
 }
 /// <summary>
 /// Returns a string that represents the current <see cref="TridionDependency" />.
 /// </summary>
 /// <returns>
 /// A string that represents the current <see cref="TridionDependency" />.
 /// </returns>
 public override String ToString()
 {
     return(String.Format("{0}-{1}", mCacheRegion.ToString(), mKey));
 }