Beispiel #1
0
        // private CacheEntryRemovedCallback callback = null;

        public static void AddToCache(String CacheKeyName, Object CacheItem, CachePriorityType MyCacheItemPriority)
        {
            System.Runtime.Caching.CacheItemPolicy policy = new System.Runtime.Caching.CacheItemPolicy();
            policy.Priority = (MyCacheItemPriority == CachePriorityType.Default) ?
                              System.Runtime.Caching.CacheItemPriority.Default : System.Runtime.Caching.CacheItemPriority.NotRemovable;
            policy.AbsoluteExpiration = DateTimeOffset.Now.AddHours(0.5);

            // Add inside cache
            cache.Set(CacheKeyName, CacheItem, policy);
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemoryCacheProvider" /> class.
 /// </summary>
 /// <param name="cacheEntryRemovedCallback">The cache entry removed callback.</param>
 /// <param name="cacheItemPriority">The cache item priority.</param>
 public MemoryCacheProvider(Action <CacheEntryRemovedArguments> cacheEntryRemovedCallback, CachePriorityType cacheItemPriority)
 {
     _cacheEntryRemovedCallback = cacheEntryRemovedCallback;
     _cacheItemPriority         = cacheItemPriority;
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemoryCacheProvider" /> class.
 /// </summary>
 /// <param name="callback">The callback.</param>
 public MemoryCacheProvider(Action <CacheEntryRemovedArguments> callback)
 {
     _cacheEntryRemovedCallback = callback;
     _cacheItemPriority         = CachePriorityType.Default;
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MemoryCacheProvider"/> class.
 /// </summary>
 public MemoryCacheProvider()
 {
     _cacheEntryRemovedCallback = DoNothing;
     _cacheItemPriority         = CachePriorityType.Default;
 }