public async Task <IEnumerable <Message> > GetChatMessagesAsync(int id)
        {
            await _semaphore.WaitAsync();

            try
            {
                if (_messageCache.ContainsKey(id))
                {
                    _messageCache[id].RemoveAll(x => x.ExpirationDate != null && x.ExpirationDate < DateTime.Now);
                    return(_messageCache[id]);
                }

                var response = await _client.GetAsync($"messages/chats/{id}").ConfigureAwait(false);

                if (!response.IsSuccessStatusCode)
                {
                    return(null);
                }

                var ret = await response.Content.ReadAsAsync <List <Message> >();

                _messageCache.Add(id, new List <Message>(ret));
                return(ret);
            }
            catch (Exception e)
            {
                Trace.Write(e.ToString());
                throw;
            }
            finally
            {
                _semaphore.Release();
            }
        }
示例#2
0
            public void ReturnsRightValueForExistingKey()
            {
                var cache = new CacheStorage<string, int>();
                cache.Add("1", 1);
                cache.Add("2", 2);

                Assert.AreEqual(2, cache.Get("2"));
            }
示例#3
0
            public void DoesNotAddExistingValueForFalseOverride()
            {
                var cache = new CacheStorage <string, int>();

                cache.Add("1", 1);
                cache.Add("1", 2, false);

                Assert.AreEqual(1, cache["1"]);
            }
示例#4
0
            public void AddsNonExistingValueForTrueOverride()
            {
                var cache = new CacheStorage <string, int>();

                cache.Add("1", 1);
                cache.Add("1", 2, true);

                Assert.AreEqual(2, cache["1"]);
            }
示例#5
0
            public void ReturnsRightValueForExistingKey()
            {
                var cache = new CacheStorage <string, int>();

                cache.Add("1", 1);
                cache.Add("2", 2);

                Assert.AreEqual(2, cache.Get("2"));
            }
示例#6
0
            public void ReturnsTrueForExistingKey()
            {
                var cache = new CacheStorage <string, int>();

                cache.Add("1", 1);
                cache.Add("2", 2);

                Assert.IsTrue(cache.Contains("2"));
            }
示例#7
0
            public void RaisesExpiringEventWithCorrectEventArgsWhenItemExpires()
            {
                var key = "1";
                var expirationPolicy   = new SlidingExpirationPolicy(TimeSpan.FromMilliseconds(250));
                var value              = 1;
                var evKey              = (string)null;
                var evExpirationPolicy = default(ExpirationPolicy);
                var evValue            = 0;

                var cache = new CacheStorage <string, int>();

                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);
                cache.Expiring += (sender, e) =>
                {
                    evKey = e.Key;
                    evExpirationPolicy = e.ExpirationPolicy;
                    evValue            = e.Value;
                };

                cache.Add(key, value, expirationPolicy);

                ThreadHelper.Sleep(750);

                Assert.AreEqual(key, evKey);
                Assert.AreEqual(expirationPolicy, evExpirationPolicy);
                Assert.AreEqual(value, evValue);
            }
        public async Task <Chat> GetDialogChatAsync(int otherId)
        {
            if (_dialogCache.ContainsKey(otherId))
            {
                var chatId = _dialogCache[otherId];
                lock (_lock)
                    if (_poller != null)
                    {
                        lock (_poller.ChatsStorage)
                            if (_poller.ChatsStorage.ContainsKey(chatId))
                            {
                                return(_poller.ChatsStorage[chatId]);
                            }
                    }
            }

            var response = await _client.GetAsync($"chats/dialog/{UserId}/{otherId}").ConfigureAwait(false);

            if (response.IsSuccessStatusCode)
            {
                var ret = await response.Content.ReadAsAsync <Chat>();

                if (!_dialogCache.ContainsKey(otherId))
                {
                    _dialogCache.Add(otherId, ret.Id);
                }
                return(ret);
            }
            return(null);
        }
示例#9
0
            public void RaisesExpiredEventWithCorrectEventArgsWhenItemExpires()
            {
                var dispose   = true;
                var key       = "1";
                var value     = 1;
                var evDispose = false;
                var evKey     = (string)null;
                var evValue   = 0;

                var cache = new CacheStorage <string, int>();

                cache.DisposeValuesOnRemoval  = dispose;
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);
                cache.Expired += (sender, e) =>
                {
                    evDispose = e.Dispose;
                    evKey     = e.Key;
                    evValue   = e.Value;
                };

                cache.Add(key, value, expiration: new TimeSpan(0, 0, 0, 0, 250));

                ThreadHelper.Sleep(750);

                Assert.AreEqual(dispose, evDispose);
                Assert.AreEqual(key, evKey);
                Assert.AreEqual(value, evValue);
            }
示例#10
0
            public static string AddSearchVM(SearchVM searchVM)
            {
                var query = searchVM.SearchQuery.ToString();

                AddHistory(searchVM.Keyword);
                srCache.Add(query, searchVM);
                return(query);
            }
示例#11
0
            public static string AddSearchVM(FavoritesVM searchVM)
            {
                var query = searchVM.SearchQuery;

                AddHistory(searchVM.Keyword);
                srCache.Add(query, searchVM);
                return(query);
            }
示例#12
0
            public void AddsNonExistingValue()
            {
                var cache = new CacheStorage <string, int>();

                cache.Add("1", 1);

                Assert.AreEqual(1, cache["1"]);
            }
示例#13
0
            public void DoesNotRaiseExpiredEventOnClearStorage()
            {
                var counter = 0;
                var cache   = new CacheStorage <string, int>();

                cache.Add("1", 1);
                cache.Expired += (sender, e) => counter++;

                Assert.AreEqual(0, counter);
            }
示例#14
0
            public void ReturnsCachedItem()
            {
                var cache = new CacheStorage <string, int>();

                cache.Add("1", 1);
                var value = cache.GetFromCacheOrFetch("1", () => 2);

                Assert.IsTrue(cache.Contains("1"));
                Assert.AreEqual(1, cache["1"]);
                Assert.AreEqual(1, value);
            }
示例#15
0
            public void AddsItemToCacheWithOverrideAndReturnsIt()
            {
                var cache = new CacheStorage <string, int>();

                cache.Add("1", 1);
                var value = cache.GetFromCacheOrFetch("1", () => 2, true);

                Assert.IsTrue(cache.Contains("1"));
                Assert.AreEqual(2, cache["1"]);
                Assert.AreEqual(2, value);
            }
示例#16
0
            public void AutomaticallyRemovesExpiredItems()
            {
                var cache = new CacheStorage <string, int>();

                cache.Add("1", 1, expiration: new TimeSpan(0, 0, 1));

                Assert.IsTrue(cache.Contains("1"));

                ThreadHelper.Sleep(2000);

                Assert.IsFalse(cache.Contains("1"));
            }
示例#17
0
            public void AutomaticallyRemovesExpiredItemsOfACacheStorageWithDefaultExpirationPolicyInitializationCode()
            {
                var cache = new CacheStorage <string, int>(() => ExpirationPolicy.Duration(TimeSpan.FromMilliseconds(500)));

                cache.Add("1", 1);

                Assert.IsTrue(cache.Contains("1"));

                ThreadHelper.Sleep(2000);

                Assert.IsFalse(cache.Contains("1"));
            }
示例#18
0
            public void RemovesExistingValue()
            {
                var cache = new CacheStorage <string, int>();

                cache.Add("1", 1);

                Assert.IsTrue(cache.Contains("1"));

                cache.Remove("1");

                Assert.IsFalse(cache.Contains("1"));
            }
示例#19
0
            public void AutomaticallyRemovesExpiredItems()
            {
                var cache = new CacheStorage <string, int>();

                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);

                cache.Add("1", 1, expiration: new TimeSpan(0, 0, 0, 0, 250));

                Assert.IsTrue(cache.Contains("1"));

                ThreadHelper.Sleep(750);

                Assert.IsFalse(cache.Contains("1"));
            }
示例#20
0
            public void IsAutomaticallyEnabledWhenStartedDisabledButAddingItemWithCustomExpirationPolicy()
            {
                var cache = new CacheStorage <string, int>();

                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);

                cache.Add("1", 1, expiration: new TimeSpan(0, 0, 0, 0, 250));

                Assert.IsTrue(cache.Contains("1"));

                ThreadHelper.Sleep(750);

                Assert.IsFalse(cache.Contains("1"));
            }
示例#21
0
            public void DoesNotDisposeItemsOnClearWhenDisposingNotEnabled()
            {
                var disposable = new CustomDisposable();
                var cache      = new CacheStorage <string, CustomDisposable>();

                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);

                cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250));

                Assert.IsFalse(disposable.IsDiposed);

                cache.Clear();

                Assert.IsFalse(disposable.IsDiposed);
            }
示例#22
0
            public void DisposesItemOnRemoveWhenDisposingEnabled()
            {
                var disposable = new CustomDisposable();
                var cache      = new CacheStorage <string, CustomDisposable>();

                cache.DisposeValuesOnRemoval  = true;
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);

                cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250));

                Assert.IsFalse(disposable.IsDiposed);

                cache.Remove("disposable");

                Assert.IsTrue(disposable.IsDiposed);
            }
示例#23
0
            public void DisposesExpiredItemWhenDisposingNotEnabledButForcedByEventArgs()
            {
                var disposable = new CustomDisposable();
                var cache      = new CacheStorage <string, CustomDisposable>();

                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);
                cache.Expired += (sender, e) =>
                {
                    e.Dispose = true;
                };

                cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250));

                ThreadHelper.Sleep(750);

                Assert.IsTrue(disposable.IsDiposed);
            }
示例#24
0
            public void DoesNotDisposeExpiredItemWhenDisposingEnabledButCanceledByEventArgs()
            {
                var disposable = new CustomDisposable();
                var cache      = new CacheStorage <string, CustomDisposable>();

                cache.DisposeValuesOnRemoval  = true;
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);
                cache.Expired += (sender, e) =>
                {
                    e.Dispose = false;
                };

                cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250));

                ThreadHelper.Sleep(750);

                Assert.IsFalse(disposable.IsDiposed);
            }
示例#25
0
            public void ItemStaysInCacheWhenExpiringEventIsCanceled()
            {
                var key   = "1";
                var value = 1;

                var cache = new CacheStorage <string, int>();

                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);
                cache.Expiring += (sender, e) =>
                {
                    e.Cancel = true;
                };

                cache.Add(key, value, expiration: new TimeSpan(0, 0, 0, 0, 250));

                ThreadHelper.Sleep(750);

                Assert.IsTrue(cache.Contains(key));
            }
 public void SetChatUserInfo(int userId, int chatId, ChatUserInfo chatUserInfo)
 {
     lock (ChatUserInfosCache)
     {
         var key = new ChatUserId(userId, chatId);
         if (ChatUserInfosCache.ContainsKey(key))
         {
             ChatUserInfosCache[key] = chatUserInfo;
         }
         else
         {
             ChatUserInfosCache.Add(key, chatUserInfo);
         }
         if (_newChatUserInfosHandlers.ContainsKey(key))
         {
             _newChatUserInfosHandlers[key]?.Invoke(this, chatUserInfo);
         }
     }
 }
示例#27
0
        public static GalleryVM GetVM(Gallery gallery)
        {
            var gi = new GalleryInfo(gallery.ID, gallery.Token);

            if (Cache.TryGet(gi, out var vm))
            {
                vm.Gallery = gallery;
                if (gallery.Count <= vm.currentIndex)
                {
                    vm.currentIndex = -1;
                }
            }
            else
            {
                vm = new GalleryVM(gallery);
                Cache.Add(gi, vm);
            }
            return(vm);
        }
示例#28
0
            public void ThrowsArgumentNullExceptionForNullValueIfNotAllowNullValues()
            {
                var cache = new CacheStorage<string, object>();

                ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => cache.Add(null, null));
            }
示例#29
0
            public void AddsNonExistingValue()
            {
                var cache = new CacheStorage<string, int>();
                cache.Add("1", 1);

                Assert.AreEqual(1, cache["1"]);
            }
示例#30
0
            public void AddsNonExistingValueForTrueOverride()
            {
                var cache = new CacheStorage<string, int>();
                cache.Add("1", 1);
                cache.Add("1", 2, true);

                Assert.AreEqual(2, cache["1"]);
            }
示例#31
0
            public void ThrowsArgumentNullExceptionForNullValueIfNotAllowNullValues()
            {
                var cache = new CacheStorage <string, object>();

                ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => cache.Add(null, null));
            }
示例#32
0
            public void AutomaticallyRemovesExpiredItems()
            {
                var cache = new CacheStorage<string, int>();
     			
     			cache.Add("1", 1, expiration: new TimeSpan(0, 0, 1));

				Assert.IsTrue(cache.Contains("1"));

				ThreadHelper.Sleep(1500);

				Assert.IsFalse(cache.Contains("1"));
			}
示例#33
0
            public void ReturnsCachedItem()
            {
                var cache = new CacheStorage<string, int>();

                cache.Add("1", 1);
                var value = cache.GetFromCacheOrFetch("1", () => 2);

                Assert.IsTrue(cache.Contains("1"));
                Assert.AreEqual(1, cache["1"]);
                Assert.AreEqual(1, value);
            }
示例#34
0
            public void DoesNotRaiseExpiredEventOnClearStorage()
            {
                var counter = 0;
                var cache = new CacheStorage<string, int>();
                cache.Add("1", 1);
                cache.Expired += (sender, e) => counter++;

                Assert.AreEqual(0, counter);
            }
示例#35
0
            public void IsAutomaticallyEnabledWhenStartedDisabledButAddingItemWithCustomExpirationPolicy()
            {
                var cache = new CacheStorage<string, int>();
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);

                cache.Add("1", 1, expiration: new TimeSpan(0, 0, 0, 0, 250));

                Assert.IsTrue(cache.Contains("1"));

                ThreadHelper.Sleep(750);

                Assert.IsFalse(cache.Contains("1"));
            }
示例#36
0
            public void DisposesExpiredItemWhenDisposingNotEnabledButForcedByEventArgs()
            {
                var disposable = new CustomDisposable();
                var cache = new CacheStorage<string, CustomDisposable>();
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);
                cache.Expired += (sender, e) =>
                {
                    e.Dispose = true;
                };

                cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250));

                ThreadHelper.Sleep(750);

                Assert.IsTrue(disposable.IsDiposed);
            }
示例#37
0
            public void DoesNotDisposeItemsOnClearWhenDisposingNotEnabled()
            {
                var disposable = new CustomDisposable();
                var cache = new CacheStorage<string, CustomDisposable>();
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);

                cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250));

                Assert.IsFalse(disposable.IsDiposed);

                cache.Clear();

                Assert.IsFalse(disposable.IsDiposed);
            }
示例#38
0
            public void DoesNotDisposeExpiredItemWhenDisposingEnabledButCanceledByEventArgs()
            {
                var disposable = new CustomDisposable();
                var cache = new CacheStorage<string, CustomDisposable>();
                cache.DisposeValuesOnRemoval = true;
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);
                cache.Expired += (sender, e) =>
                {
                    e.Dispose = false;
                };

                cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250));

                ThreadHelper.Sleep(750);

                Assert.IsFalse(disposable.IsDiposed);
            }
示例#39
0
            public void ThrowsArgumentNullExceptionForNullKey()
            {
                var cache = new CacheStorage<string, int>();

                ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => cache.Add(null, 1));
            }
示例#40
0
 public void SaveToCache(Uri iconUri, byte[] streamContent)
 {
     _cache.Add(iconUri.ToString(), streamContent, StoringPolicy);
 }
示例#41
0
            public void AddsItemToCacheWithOverrideAndReturnsIt()
            {
                var cache = new CacheStorage<string, int>();

                cache.Add("1", 1);
                var value = cache.GetFromCacheOrFetch("1", () => 2, true);

                Assert.IsTrue(cache.Contains("1"));
                Assert.AreEqual(2, cache["1"]);
                Assert.AreEqual(2, value);
            }
示例#42
0
            public void RaisesExpiringEventWithCorrectEventArgsWhenItemExpires()
            {
                var key = "1";
                var expirationPolicy = new SlidingExpirationPolicy(TimeSpan.FromMilliseconds(250));
                var value = 1;
                var evKey = (string)null;
                var evExpirationPolicy = default(ExpirationPolicy);
                var evValue = 0;

                var cache = new CacheStorage<string, int>();
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);
                cache.Expiring += (sender, e) =>
                {
                    evKey = e.Key;
                    evExpirationPolicy = e.ExpirationPolicy;
                    evValue = e.Value;
                };

                cache.Add(key, value, expirationPolicy);

                ThreadHelper.Sleep(750);

                Assert.AreEqual(key, evKey);
                Assert.AreEqual(expirationPolicy, evExpirationPolicy);
                Assert.AreEqual(value, evValue);
            }
示例#43
0
            public void ReturnsTrueForExistingKey()
            {
                var cache = new CacheStorage<string, int>();
                cache.Add("1", 1);
                cache.Add("2", 2);

                Assert.IsTrue(cache.Contains("2"));
            }
示例#44
0
            public void AutomaticallyRemovesExpiredItemsOfACacheStorageWithDefaultExpirationPolicyInitializationCode()
            {
                var cache = new CacheStorage<string, int>(() => ExpirationPolicy.Duration(TimeSpan.FromMilliseconds(250)));
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);

                cache.Add("1", 1);

                Assert.IsTrue(cache.Contains("1"));

                ThreadHelper.Sleep(750);

                Assert.IsFalse(cache.Contains("1"));
            }
示例#45
0
            public void RemovesExistingValue()
            {
                var cache = new CacheStorage<string, int>();
                cache.Add("1", 1);

                Assert.IsTrue(cache.Contains("1"));

                cache.Remove("1");

                Assert.IsFalse(cache.Contains("1"));
            }
示例#46
0
            public void ItemStaysInCacheWhenExpiringEventIsCanceled()
            {
                var key = "1";
                var value = 1;

                var cache = new CacheStorage<string, int>();
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);
                cache.Expiring += (sender, e) =>
                {
                    e.Cancel = true;
                };

                cache.Add(key, value, expiration: new TimeSpan(0, 0, 0, 0, 250));

                ThreadHelper.Sleep(750);

                Assert.IsTrue(cache.Contains(key));
            }
示例#47
0
            public void DoesNotAddExistingValueForFalseOverride()
            {
                var cache = new CacheStorage<string, int>();
                cache.Add("1", 1);
                cache.Add("1", 2, false);

                Assert.AreEqual(1, cache["1"]);
            }
示例#48
0
            public void ThrowsArgumentNullExceptionForNullKey()
            {
                var cache = new CacheStorage <string, int>();

                ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => cache.Add(null, 1));
            }
示例#49
0
            public void RaisesExpiredEventWithCorrectEventArgsWhenItemExpires()
            {
                var dispose = true;
                var key = "1";
                var value = 1;
                var evDispose = false;
                var evKey = (string)null;
                var evValue = 0;

                var cache = new CacheStorage<string, int>();
                cache.DisposeValuesOnRemoval = dispose;
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);
                cache.Expired += (sender, e) =>
                {
                    evDispose = e.Dispose;
                    evKey = e.Key;
                    evValue = e.Value;
                };

                cache.Add(key, value, expiration: new TimeSpan(0, 0, 0, 0, 250));

                ThreadHelper.Sleep(750);

                Assert.AreEqual(dispose, evDispose);
                Assert.AreEqual(key, evKey);
                Assert.AreEqual(value, evValue);
            }
示例#50
0
            public void AutomaticallyRemovesExpiredItems()
            {
                var cache = new CacheStorage<string, int>();
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);

                cache.Add("1", 1, expiration: new TimeSpan(0, 0, 0, 0, 250));

                Assert.IsTrue(cache.Contains("1"));

                ThreadHelper.Sleep(750);

                Assert.IsFalse(cache.Contains("1"));
            }
        protected override Task <HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            HttpStatusCode statusCode;
            string         token;

            // determine whether a jwt exists or not
            if (!TryRetrieveToken(request, out token))
            {
                statusCode = HttpStatusCode.Unauthorized;
                return(base.SendAsync(request, cancellationToken));
            }

            try
            {
                var secretKey     = ConfigurationManager.AppSettings["JWT_SECRET_KEY"];
                var audienceToken = ConfigurationManager.AppSettings["JWT_AUDIENCE_TOKEN"];
                var issuerToken   = ConfigurationManager.AppSettings["JWT_ISSUER_TOKEN"];
                var securityKey   = new SymmetricSecurityKey(System.Text.Encoding.Default.GetBytes(secretKey));

                SecurityToken             securityToken;
                var                       tokenHandler         = new System.IdentityModel.Tokens.Jwt.JwtSecurityTokenHandler();
                TokenValidationParameters validationParameters = new TokenValidationParameters()
                {
                    ValidAudience            = audienceToken,
                    ValidIssuer              = issuerToken,
                    ValidateLifetime         = true,
                    ValidateIssuerSigningKey = true,
                    LifetimeValidator        = this.LifetimeValidator,
                    IssuerSigningKey         = securityKey
                };

                //Delete currentUserId and UserName in Cache
                CurrentUser.DeleteId();
                CurrentUser.DeleteName();

                // Extract and assign Current Principal and user
                Thread.CurrentPrincipal  = tokenHandler.ValidateToken(token, validationParameters, out securityToken);
                HttpContext.Current.User = tokenHandler.ValidateToken(token, validationParameters, out securityToken);


                string   userName  = Thread.CurrentPrincipal.Identity.Name;
                string[] userValue = userName.Split(',');

                this.currentUserName = userValue[0];
                this.currentUserId   = Convert.ToInt64(userValue[1]);

                //Cache estorage by 5 minutes
                CacheStorage.Add("currentUserName", currentUserName, DateTimeOffset.UtcNow.AddMinutes(5));
                CacheStorage.Add("currentUserId", currentUserId, DateTimeOffset.UtcNow.AddMinutes(5));

                return(base.SendAsync(request, cancellationToken));
            }
            catch (SecurityTokenValidationException)
            {
                statusCode = HttpStatusCode.Unauthorized;
            }
            catch (Exception)
            {
                statusCode = HttpStatusCode.InternalServerError;
            }

            return(Task <HttpResponseMessage> .Factory.StartNew(() => new HttpResponseMessage(statusCode) { }));
        }
示例#52
0
            public void DisposesItemOnRemoveWhenDisposingEnabled()
            {
                var disposable = new CustomDisposable();
                var cache = new CacheStorage<string, CustomDisposable>();
                cache.DisposeValuesOnRemoval = true;
                cache.ExpirationTimerInterval = TimeSpan.FromMilliseconds(250);

                cache.Add("disposable", disposable, expiration: TimeSpan.FromMilliseconds(250));

                Assert.IsFalse(disposable.IsDiposed);

                cache.Remove("disposable");

                Assert.IsTrue(disposable.IsDiposed);
            }