コード例 #1
0
        public static T GetOrCreate <T>(ICacheService cacheService, QueryBuilder queryBuilder, Func <T> getData, int cacheDurationInSeconds, SqlSugarClient context)
        {
            CacheKey key       = CacheKeyBuider.GetKey(context, queryBuilder);
            string   keyString = key.ToString();
            var      result    = cacheService.GetOrCreate(keyString, getData, cacheDurationInSeconds);

            return(result);
        }
コード例 #2
0
ファイル: CacheSchemeMain.cs プロジェクト: radtek/2018lecheng
        public static T GetOrCreate <T>(ICacheService cacheService, QueryBuilder queryBuilder, Func <T> getData, int cacheDurationInSeconds, SqlSugarClient context)
        {
            CacheKey key       = CacheKeyBuider.GetKey(context, queryBuilder);
            string   keyString = key.ToString();

            foreach (var tableName in key.Tables)
            {
                //if (!mappingInfo.Any(it=>it.Key.Equals(tableName,StringComparison.CurrentCultureIgnoreCase))) {
                //    cacheService.Add<>(new KeyValuePair<string,string>(tableName, keyString));
                //}
            }

            T result = default(T);

            //if (mappingKey.IsNullOrEmpty())
            //    result = getData();
            //else
            //{
            //    result = cacheService.GetOrCreate("", () => getData(), cacheDurationInSeconds);
            //}
            return(result);
        }