Beispiel #1
0
        private async Task <bool> AddToCache(CachingStrategyContext cachingStrategyContext, string functionName, string key, object retStr, short minutesBeforeExpiration)
        {
            await Task.FromResult(1);

            string strCacheKey = string.Concat(functionName, "-", key);

            return(cachingStrategyContext.CacheAdd(strCacheKey, retStr, minutesBeforeExpiration));
        }
Beispiel #2
0
        public async Task <bool> AddToRepositoryCache(string functionName, string key, object obj, short minutesBeforeExpiration)
        {
            await Task.FromResult(1);

            CachingStrategyContext    _CachingStrategyContext    = IResolver.Current.CachingStrategyContext;
            CachingRepositoryStrategy _CachingRepositoryStrategy = IResolver.Current.CachingRepositoryStrategy;

            _CachingStrategyContext.SetStrategy(_CachingRepositoryStrategy);

            return(await AddToCache(_CachingStrategyContext, functionName, key, obj, minutesBeforeExpiration));
        }
Beispiel #3
0
        public async Task <bool> AddToModuleCache(string functionName, string key, string retStr)
        {
            await Task.FromResult(1);

            CachingStrategyContext _CachingStrategyContext = IResolver.Current.CachingStrategyContext;
            CachingModuleStrategy  _CachingModuleStrategy  = IResolver.Current.CachingModuleStrategy;

            _CachingStrategyContext.SetStrategy(_CachingModuleStrategy);

            return(await AddToCache(_CachingStrategyContext, functionName, key, retStr));
        }
Beispiel #4
0
        public async Task ClearModuleCache()
        {
            await Task.FromResult(1);

            CachingStrategyContext _CachingStrategyContext = IResolver.Current.CachingStrategyContext;
            CachingModuleStrategy  _CachingModuleStrategy  = IResolver.Current.CachingModuleStrategy;

            _CachingStrategyContext.SetStrategy(_CachingModuleStrategy);

            await ClearCache(_CachingStrategyContext);
        }
Beispiel #5
0
        public object GetDataFromRepositoryCache(string functionName, string key)
        {
            CachingStrategyContext    _CachingStrategyContext    = IResolver.Current.CachingStrategyContext;
            CachingRepositoryStrategy _CachingRepositoryStrategy = IResolver.Current.CachingRepositoryStrategy;

            _CachingStrategyContext.SetStrategy(_CachingRepositoryStrategy);

            string strCacheKey = string.Concat(functionName, "-", key);
            var    objCache    = _CachingStrategyContext.CacheGetFromKey(strCacheKey);

            return(objCache);
        }
Beispiel #6
0
        public string GetMessageFromModuleCache(string functionName, string key)
        {
            CachingStrategyContext _CachingStrategyContext = IResolver.Current.CachingStrategyContext;
            CachingModuleStrategy  _CachingModuleStrategy  = IResolver.Current.CachingModuleStrategy;

            _CachingStrategyContext.SetStrategy(_CachingModuleStrategy);

            string retStr     = "";
            string loadingStr = "";

            string strCacheKey = string.Concat(functionName, "-", key);
            var    objCache    = _CachingStrategyContext.CacheGetFromKey(strCacheKey);

            if (objCache != null)
            {
                loadingStr = "\n**(cached data^)**";
                retStr     = (string)objCache;
                return(string.Concat(loadingStr, retStr));
            }
            return(string.Empty);
        }
Beispiel #7
0
        private async Task ClearCache(CachingStrategyContext cachingStrategyContext)
        {
            await Task.FromResult(1);

            cachingStrategyContext.ClearCache();
        }
Beispiel #8
0
 public CacheClient(SettingsTripleZeroRepository settingsTripleZeroRepository, SettingsTripleZeroBot settingsTripleZeroBot)
 {
     _cachingStrategyContext    = new CachingStrategyContext();
     _cachingModuleStrategy     = new CachingModuleStrategy(settingsTripleZeroBot);
     _cachingRepositoryStrategy = new CachingRepositoryStrategy(settingsTripleZeroRepository);
 }
Beispiel #9
0
 public CacheClient(CachingStrategyContext cachingStrategyContext, CachingModuleStrategy cachingModuleStrategy, CachingRepositoryStrategy cachingRepositoryStrategy)
 {
     _cachingStrategyContext    = cachingStrategyContext;
     _cachingModuleStrategy     = cachingModuleStrategy;
     _cachingRepositoryStrategy = cachingRepositoryStrategy;
 }