/// <summary>
 /// 清空所有缓存
 /// </summary>
 public void FlushAllCache()
 {
     if (CacheStorageManager.IsExist(BankinateConst.GetTableCacheKeysCacheKey(DbContext.DataBaseName), out HashSet <string> keys))
     {
         foreach (var item in keys)
         {
             CacheStorageManager.Delete(item);
         }
     }
 }
        /// <summary>
        /// 后台扫描全表数据
        /// </summary>
        /// <typeparam name="TEntity"></typeparam>
        /// <param name="dbContext">上下文</param>
        /// <param name="tableCacheTimeSpan">tableCache过期时间</param>
        private void ScanTableBackground <TEntity>(TimeSpan tableCacheTimeSpan) where TEntity : class
        {
            string scanKey = $"{BankinateConst.CacheKey_TableScanning}{DbContext.CollectionName}";

            //1.判断正在扫描键是否存在,如果存在,则返回null,继续等待扫描任务完成
            if (CacheStorageManager.IsExist(scanKey))
            {
                return;
            }
            //2.如果没有扫描键,则执行后台扫描任务
            Task.Run(() =>
            {
                //设置扫描键,标识当前正在进行扫描
                CacheStorageManager.Put(scanKey, 1, BankinateConst.SpanScaningKeyExpiredTime);
                //对扫描任务加锁,防止多线程环境多次执行任务
                lock (tableScaningLocker)
                {
                    var tableName = TableAttribute.GetName(typeof(TEntity));
                    //双重校验当前缓存是否存在TableCache,防止多个进程在锁外等待,所释放后再次执行
                    if (CacheStorageManager.IsExist(GetTableCacheKey(tableName)))
                    {
                        return;
                    }
                    //如果过期时间为0,则取上下文的过期时间
                    TimeSpan timeSpan = tableCacheTimeSpan == TimeSpan.Zero ? DbContext.TableCacheExpiredTimeSpan : tableCacheTimeSpan;
                    //执行扫描全表任务,并将结果存入缓存中
                    var data = DbContext.GetFullCollectionData <TEntity>();
                    if (data != null)
                    {
                        CacheStorageManager.Put(GetTableCacheKey(tableName), data, DbContext.TableCacheExpiredTimeSpan);
                    }
                }
                //将扫描键移除,表示已经扫描完成
                CacheStorageManager.Delete(scanKey);
            });
        }
 /// <summary>
 /// 清空单个表相关的所有缓存
 /// </summary>
 /// <param name="dbContext"></param>
 public void FlushCollectionCache(string collectionName = null)
 {
     CacheStorageManager.Delete(GetTableCacheKey(collectionName));
 }