public LockerReloader(ILockerRetrieval lockerRetrieval, ICacheClient cacheClient, ICacheLock cacheLock, IUserTokenCache userTokenCache)
 {
     _lockerRetrieval = lockerRetrieval;
     _cacheClient     = cacheClient;
     _cacheLock       = cacheLock;
     _userTokenCache  = userTokenCache;
 }
Пример #2
0
 private static ICache <TKey, TValue> MRU <TKey, TValue>(ICacheLock cacheLock, int totalCapacity)
 {
     return(new Cache <TKey, TValue>(
                MRU_Policy <TKey, TValue>(),
                cacheLock,
                totalCapacity));
 }
        /// <summary>
        /// Ensure that lock cannot be obtained by other threads.
        /// </summary>
        /// <param name="getLock">Get lock function.</param>
        /// <param name="sharedLock">Shared lock.</param>
        private static void EnsureCannotLock(Func <ICacheLock> getLock, ICacheLock sharedLock)
        {
            var task = new Task(() =>
            {
                Assert.IsFalse(sharedLock.TryEnter());
                Assert.IsFalse(sharedLock.TryEnter(TimeSpan.FromMilliseconds(100)));

                using (var otherLock = getLock())
                {
                    Assert.IsFalse(otherLock.TryEnter());
                    Assert.IsFalse(otherLock.TryEnter(TimeSpan.FromMilliseconds(100)));
                }
            });

            task.Start();
            task.Wait();
        }
Пример #4
0
 public DataCache(ICacheStore cacheStore, ICacheLock locker, ICacheTimePolicy cacheTimePolicy)
 {
     _CacheStore      = cacheStore;
     _CacheTimePolicy = cacheTimePolicy;
     _Locker          = locker;
 }
Пример #5
0
 public Cache(ICachePolicy <TKey, TValue> policy, ICacheLock cacheLock, long totalCapacity)
 {
     this.policy        = policy;
     this.cacheLock     = cacheLock;
     this.totalCapacity = totalCapacity;
 }
Пример #6
0
 private static ICache <TKey, TValue> LRU <TKey, TValue>(IDictionary <TKey, ICacheEntry <TKey, TValue> > entries, ICacheLock cacheLock, int totalCapacity)
 {
     return(new Cache <TKey, TValue>(
                LRU_Policy <TKey, TValue>(),
                cacheLock,
                totalCapacity));
 }
Пример #7
0
 public ReadWriteCache(ICacheLock locker)
 {
     _asyncReaderWriterLock = locker;
 }