Example #1
0
        public static void SaveEvictingItem(this IEvictingStore store, IHasId obj, IExpirable evictingCondition)
        {
            if (store == null)
            {
                return;
            }

            store.Commit(new CommitBag().MarkItemSaved(obj), evictingCondition);
        }
Example #2
0
        public static void SaveOneTimeItem(this IEvictingStore store, IHasId obj)
        {
            if (store == null)
            {
                return;
            }

            var expiry = EvictionPolicy.BuildTouchLimitExpirable(1);

            store.Commit(new CommitBag().MarkItemSaved(obj), expiry);
        }
Example #3
0
 /// <summary>
 /// ctor with no default eviction condition factory.  any items added will not be evicted without an eviction being set
 /// </summary>
 /// <param name="decorated"></param>
 /// <param name="backgroundIntervalMSecs"></param>
 public CacheDecoration(IStore decorated, IEvictingStore cachingStore)
     : base(decorated)
 {
     Condition.Requires(cachingStore).IsNotNull();
     this.CachingStore = cachingStore;
 }
Example #4
0
 /// <summary>
 /// adds caching to the store, with the cache supplied.  Note: this is how we might inject
 /// a distributed cache.
 /// </summary>
 /// <param name="decorated"></param>
 /// <param name="cachingStore"></param>
 /// <returns></returns>
 public static CacheDecoration Caching(this IStore decorated, IEvictingStore cachingStore)
 {
     Condition.Requires(decorated).IsNotNull();
     return new CacheDecoration(decorated, cachingStore);
 }
Example #5
0
 /// <summary>
 /// ctor with no default eviction condition factory.  any items added will not be evicted without an eviction being set
 /// </summary>
 /// <param name="decorated"></param>
 /// <param name="backgroundIntervalMSecs"></param>
 public CacheDecoration(IStore decorated, IEvictingStore cachingStore)
     : base(decorated)
 {
     Condition.Requires(cachingStore).IsNotNull();
     this.CachingStore = cachingStore;
 }
Example #6
0
 /// <summary>
 /// adds caching to the store, with the cache supplied.  Note: this is how we might inject
 /// a distributed cache.
 /// </summary>
 /// <param name="decorated"></param>
 /// <param name="cachingStore"></param>
 /// <returns></returns>
 public static CacheDecoration Caching(this IStore decorated, IEvictingStore cachingStore)
 {
     Condition.Requires(decorated).IsNotNull();
     return(new CacheDecoration(decorated, cachingStore));
 }