Ejemplo n.º 1
0
        public virtual void Add(string cacheKey, object value, CacheOptions options = null)
        {
            if (options == null)
            {
                options = new CacheOptions();
            }

            context.HttpContext.Cache.Add(tablePrefix + cacheKey, value, GetCacheDependency(options), options.AbsoluteExpiration, options.SlidingExpiration, options.Priority, options.RemoveCallback);
        }
Ejemplo n.º 2
0
        public virtual T GetOrCreate <T>(string cacheKey, Func <T> factory, CacheOptions options = null) where T : class
        {
            var value = Get <T>(cacheKey);

            if (value != null)
            {
                return(value);
            }

            value = factory();
            Add(cacheKey, value, options);
            return(value);
        }
Ejemplo n.º 3
0
        public virtual CacheDependency GetCacheDependency(CacheOptions options)
        {
            if (!options.ContentDependency)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(sqlCacheDependency))
            {
                return(new ContentCacheDependency(persister));                // TODO ensure proper eviction with XML repo
            }
            return(new SqlCacheDependency(sqlCacheDependency, tablePrefix + "Item"));
        }
Ejemplo n.º 4
0
        protected virtual CacheDependency GetCacheDependency(CacheOptions options)
        {
            if (!options.ContentDependency)
            {
                return(null);
            }

            if (string.IsNullOrEmpty(sqlCacheDependency))
            {
                return(new ContentCacheDependency(persister));
            }

            return(new SqlCacheDependency(sqlCacheDependency, tablePrefix + "item"));
        }