コード例 #1
0
        public void RemoveByIdResourceUriTest()
        {
            var cacheKey      = new CacheKey("/api/Cars", new[] { "1234", "abcdef" }, "/api/Cars/*");
            var cacheKey2     = new CacheKey("/api/Cars", new[] { "1234", "abcdefgh", "/api/Cars/+" });
            var documentStore = new EmbeddableDocumentStore()
            {
                RunInMemory = true
            }.Initialize();

            var store = new RavenDbEntityTagStore(documentStore);
            var value = new TimedEntityTagHeaderValue("\"abcdef1234\"")
            {
                LastModified = DateTime.Now
            };


            // first remove them
            store.RemoveAllByRoutePattern(cacheKey.RoutePattern);

            // add
            store.AddOrUpdate(cacheKey, value);
            store.AddOrUpdate(cacheKey2, value);

            // delete
            Assert.AreEqual(2, store.RemoveResource("/api/Cars"));
        }
コード例 #2
0
ファイル: IntegrationTests.cs プロジェクト: Nangal/CacheCow
        public void RemoveByIdResourceUriTest()
        {
            var cacheKey = new CacheKey("/api/Cars", new[] { "1234", "abcdef" }, "/api/Cars/*");
            var cacheKey2 = new CacheKey("/api/Cars", new[] { "1234", "abcdefgh", "/api/Cars/+" });
            var documentStore = new EmbeddableDocumentStore()
            {
                RunInMemory = true
            }.Initialize();

            var store = new RavenDbEntityTagStore(documentStore);
            var value = new TimedEntityTagHeaderValue("\"abcdef1234\"") { LastModified = DateTime.Now };

            // first remove them
            store.RemoveAllByRoutePattern(cacheKey.RoutePattern);

            // add
            store.AddOrUpdate(cacheKey, value);
            store.AddOrUpdate(cacheKey2, value);

            // delete
            Assert.AreEqual(2, store.RemoveResource("/api/Cars"));
        }