Insert() 공개 메소드

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
리턴 void
예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
 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);
 }
예제 #7
0
 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);
 }
예제 #8
0
 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);
 }
예제 #9
0
 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);
 }
예제 #10
0
 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);
 }