public Insert ( string key, Object value, System.Web.Caching.CacheDependency dependency, System.DateTime absolute_expiration, System.TimeSpan sliding_expiration, CacheItemPriority priority, CacheItemRemovedCallback removed_callback ) : void | ||
key | string | |
value | Object | |
dependency | System.Web.Caching.CacheDependency | |
absolute_expiration | System.DateTime | |
sliding_expiration | System.TimeSpan | |
priority | CacheItemPriority | |
removed_callback | CacheItemRemovedCallback | |
return | void |
public void ItemInCacheIfWithinSlidingExpiration() { var cache = new MockCache(); var sliding_expiration = new TimeSpan(0, 0, 5); var key = view_uri.ToString(); cache.Insert(key, view_contents, null, Cache.NoAbsoluteExpiration, sliding_expiration, CacheItemPriority.Normal, null); Assert.AreEqual(cache[key], view_contents); }
public void RemovedObjectIsGone() { var cache = new MockCache(); var cache_span = new TimeSpan(0, 0, 2); var key = blob_uri.ToString(); cache.Insert(key, view_contents, null, Cache.NoAbsoluteExpiration, cache_span, CacheItemPriority.Normal, null); cache.Remove(key); Assert.That(cache[key] == null); }
public void ItemGoneFromCacheIfBeyondSlidingExpiration() { var cache = new MockCache(); var sliding_expiration = new TimeSpan(0, 0, 1); var key = view_uri.ToString(); cache.Insert(key, view_contents, null, Cache.NoAbsoluteExpiration, sliding_expiration, CacheItemPriority.Normal, null); HttpUtils.Wait(2); Assert.AreNotEqual(cache[key], view_contents); }
public void CacheWithBlobYieldsCachedBlob() { MockCache cache = new MockCache(); var cache_span = new TimeSpan(1, 0, 0); cache.Insert(blob_uri.ToString(), cached_blob_contents, null, Cache.NoAbsoluteExpiration, cache_span, CacheItemPriority.Normal, null); var indirect_fetch = CacheUtils.RetrieveBlobAndEtagFromServerCacheOrUri(cache, blob_uri); Assert.AreEqual(indirect_fetch["response_body"], cached_blob_contents); }
public void PurgeIsSuccessful() { var cache = new MockCache(); var cache_span = new TimeSpan(1, 0, 0); var key = blob_uri.ToString(); cache.Insert(key, view_contents, null, Cache.NoAbsoluteExpiration, cache_span, CacheItemPriority.Normal, null); CacheUtils.MarkBaseCacheEntryForRemoval(key, 2); var purgeable_dicts = CacheUtils.FetchPurgeableCacheDicts(); var test_dict = purgeable_dicts.Find(d => (string)d["cached_uri"] == key); Assert.That((int)test_dict["count"] == 2); CacheUtils.MaybePurgeCache(cache); Assert.That(cache[key] == null); purgeable_dicts = CacheUtils.FetchPurgeableCacheDicts(); test_dict = purgeable_dicts.Find(d => (string)d["cached_uri"] == key); Assert.That((int)test_dict["count"] == 1); }
public void ExpiredObjectIsGone() { var cache = new MockCache(); var cache_span = new TimeSpan(0, 0, 2); var key = blob_uri.ToString(); cache.Insert(key, view_contents, null, Cache.NoAbsoluteExpiration, cache_span, CacheItemPriority.Normal, null); HttpUtils.Wait(5); Assert.That(cache[blob_uri.ToString()] == null); }
public void CacheWithBlobYieldsCachedBlob() { MockCache cache = new MockCache(); var cache_span = new TimeSpan(1, 0, 0); cache.Insert(blob_uri.ToString(), cached_blob_contents, null, Cache.NoAbsoluteExpiration, cache_span, CacheItemPriority.Normal, null); var indirect_fetch = CacheUtils.RetrieveBlobAndEtagFromServerCacheOrUri(cache, blob_uri); Assert.AreEqual(indirect_fetch["response_body"], cached_blob_contents); }
public void PurgeIsSuccessful() { var cache = new MockCache(); var cache_span = new TimeSpan(1, 0, 0); var key = blob_uri.ToString(); cache.Insert(key, view_contents, null, Cache.NoAbsoluteExpiration, cache_span, CacheItemPriority.Normal, null); CacheUtils.MarkBaseCacheEntryForRemoval(key, 2); var purgeable_dicts = CacheUtils.FetchPurgeableCacheDicts(); var test_dict = purgeable_dicts.Find(d => (string)d["cached_uri"] == key); Assert.That((int)test_dict["count"] == 2); CacheUtils.MaybePurgeCache(cache); Assert.That(cache[key] == null); purgeable_dicts = CacheUtils.FetchPurgeableCacheDicts(); test_dict = purgeable_dicts.Find(d => (string)d["cached_uri"] == key); Assert.That((int)test_dict["count"] == 1); }
public void ItemInCacheIfWithinSlidingExpiration() { var cache = new MockCache(); var sliding_expiration = new TimeSpan(0, 0, 5); var key = view_uri.ToString(); cache.Insert(key, view_contents, null, Cache.NoAbsoluteExpiration, sliding_expiration, CacheItemPriority.Normal, null); Assert.AreEqual(cache[key], view_contents); }
public void ItemGoneFromCacheIfBeyondSlidingExpiration() { var cache = new MockCache(); var sliding_expiration = new TimeSpan(0, 0, 1); var key = view_uri.ToString(); cache.Insert(key, view_contents, null, Cache.NoAbsoluteExpiration, sliding_expiration, CacheItemPriority.Normal, null); HttpUtils.Wait(2); Assert.AreNotEqual(cache[key], view_contents); }