private void Execute()
        {
            _configuration = new BlendedCacheConfiguration();
            _configuration.DefaultCacheTimeout = _defaultCacheTimeout;
            _configuration.RegisterTypeConfiguration(_registeredType, _registeredConfig);

            _response = _configuration.GetCacheTimeoutForTypeOrDefault(_lookedUpType);
        }
Example #2
0
        public object SampleGetByCacheKey(int id)
        {
            var configuration = new BlendedCacheConfiguration();
            configuration.DefaultCacheKeyConverter = DefaultCacheKeyConverter.MyLookupKeyIsTheCacheKey;

            var cache = new BlendedCache.BlendedCache(new HttpContextCache(), new RuntimeMemoryCachingVolatileCache(), NullLongTermCache.NullInstance, configuration);

            var cacheKey = "SD." + id;

            var dataByInt = cache.Get<SampleData>(cacheKey);

            var dataByString = cache.Get<SampleData>(cacheKey);

            //complex really doesn't transfer, but it would be some string concat.
            //var dataByComplex = cache.Get<SampleData, SampleComplexKey>(new SampleComplexKey());

            return dataByInt;
        }
Example #3
0
        /// <summary>
        /// Will get a blended cache under the default conditions.
        /// </summary>
        /// <returns></returns>
        public static BlendedCache GetCache(IContextCache contextCache = null, IVolatileCache volatileCache = null, ILongTermCache longTermCache = null, IBlendedCacheConfiguration configuration = null, bool initialFlushMode = false)
        {
            if(contextCache == null)
                contextCache = new DictionaryContextCache();
            if(volatileCache == null)
                volatileCache = new DictionaryVolatileCache();
            if(longTermCache == null)
                longTermCache = new DictionaryLongTermCache();
            if(configuration == null)
                configuration = new BlendedCacheConfiguration();

            var cache = new BlendedCache(contextCache, volatileCache, longTermCache, configuration);

            if (initialFlushMode)
                cache.GetType().GetField("_flushMode", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(cache, true);

            return cache;
        }
Example #4
0
        private static IBlendedCache GetCache()
        {
            var contextCache = new HttpContextCache();
            var volatileCache = new RuntimeMemoryCachingVolatileCache();
            var longTermCache = new DictionaryLongTermCache();
            var configuration = new BlendedCacheConfiguration()
                {
                    DefaultCacheTimeout = new DefaultCacheTimeout()
                    {
                        VolatileTimeoutInSeconds = 5,
                        LongTermTimeoutInSeconds = 10,
                    }
                }; // this could be driven by the web.config

            return new BlendedCache.BlendedCache(contextCache, volatileCache, _dictionaryLongTermCache, configuration);
        }