Ejemplo n.º 1
0
 /// <summary>
 /// 清空所有缓存
 /// </summary>
 public void FlushAllCache()
 {
     if (CacheStorageManager.IsExist(CachingConst.GetTableCacheKeysCacheKey(DbContext.DataBaseName), out HashSet <string> keys))
     {
         foreach (var item in keys)
         {
             CacheStorageManager.Delete(item);
         }
     }
 }
Ejemplo n.º 2
0
        private string GetTableCacheKey(string collectionName = null)
        {
            string key = $"{CachingConst.CacheKey_TableCache}_{DbContext.DataBaseName}_{collectionName ?? DbContext.CollectionName}";

            //缓存键更新
            if (!CacheStorageManager.IsExist(CachingConst.GetTableCacheKeysCacheKey(DbContext.DataBaseName), out HashSet <string> keys))
            {
                keys = new HashSet <string>();
            }

            keys.Add(key);

            CacheStorageManager.Put(CachingConst.GetTableCacheKeysCacheKey(DbContext.DataBaseName), keys, CacheOptions.MaxExpiredTimeSpan);

            return(key);
        }