예제 #1
0
 /// <summary>
 /// 清空所有缓存
 /// </summary>
 public void FlushAllCache()
 {
     if (CacheStorageManager.IsExist(CoffeeSqlConst.GetQueryCacheKeysCacheKey(DbContext.DataBaseName), out HashSet <string> keys))
     {
         foreach (var item in keys)
         {
             CacheStorageManager.Delete(item);
         }
     }
 }
예제 #2
0
        /// <summary>
        /// 构建sql查询缓存的总key
        /// </summary>
        /// <returns></returns>
        private string GetQueryCacheKey(string collectionName = null)
        {
            string key = $"{CoffeeSqlConst.CacheKey_QueryCache}{collectionName ?? DbContext.CollectionName}";

            //缓存键更新
            if (!CacheStorageManager.IsExist(CoffeeSqlConst.GetQueryCacheKeysCacheKey(DbContext.DataBaseName), out HashSet <string> keys))
            {
                keys = new HashSet <string>();
            }
            keys.Add(key);
            CacheStorageManager.Put(CoffeeSqlConst.GetQueryCacheKeysCacheKey(DbContext.DataBaseName), keys, DbContext.MaxExpiredTimeSpan);
            return(key);
        }