Пример #1
0
 private object ConfigureEntry(ICacheSetContext context)
 {
     var value = (string)context.State;
     context.SetAbsoluteExpiration(TimeSpan.FromSeconds(7));
     context.SetSlidingExpiration(TimeSpan.FromSeconds(3));
     context.RegisterPostEvictionCallback(AfterEvicted, null);
     return value;
 }
Пример #2
0
        private object ConfigureEntry(ICacheSetContext context)
        {
            var value = (string)context.State;

            context.SetAbsoluteExpiration(TimeSpan.FromSeconds(7));
            context.SetSlidingExpiration(TimeSpan.FromSeconds(3));
            context.RegisterPostEvictionCallback(AfterEvicted, null);
            return(value);
        }
Пример #3
0
        /// <summary>
        /// Adds inherited trigger and absolute expiration information.
        /// </summary>
        /// <param name="link"></param>
        public static void AddEntryLink(this ICacheSetContext context, IEntryLink link)
        {
            foreach (var trigger in link.Triggers)
            {
                context.AddExpirationTrigger(trigger);
            }

            if (link.AbsoluteExpiration.HasValue)
            {
                context.SetAbsoluteExpiration(link.AbsoluteExpiration.Value);
            }
        }
Пример #4
0
        // Internal for unit testing
        internal void UpdateCacheContext(ICacheSetContext cacheSetContext, EntryLink entryLink)
        {
            if (ExpiresOn != null)
            {
                cacheSetContext.SetAbsoluteExpiration(ExpiresOn.Value);
            }

            if (ExpiresAfter != null)
            {
                cacheSetContext.SetAbsoluteExpiration(ExpiresAfter.Value);
            }

            if (ExpiresSliding != null)
            {
                cacheSetContext.SetSlidingExpiration(ExpiresSliding.Value);
            }

            if (Priority != null)
            {
                cacheSetContext.SetPriority(Priority.Value);
            }

            cacheSetContext.AddEntryLink(entryLink);
        }
Пример #5
0
 public void SetAbsoluteExpiration(TimeSpan relative)
 {
     _context.SetAbsoluteExpiration(relative);
 }
Пример #6
0
        // Internal for unit testing
        internal void UpdateCacheContext(ICacheSetContext cacheSetContext, EntryLink entryLink)
        {
            if (ExpiresOn != null)
            {
                cacheSetContext.SetAbsoluteExpiration(ExpiresOn.Value);
            }

            if (ExpiresAfter != null)
            {
                cacheSetContext.SetAbsoluteExpiration(ExpiresAfter.Value);
            }

            if (ExpiresSliding != null)
            {
                cacheSetContext.SetSlidingExpiration(ExpiresSliding.Value);
            }

            if (Priority != null)
            {
                cacheSetContext.SetPriority(Priority.Value);
            }

            cacheSetContext.AddEntryLink(entryLink);
        }