本文整理汇总了C#中Cache.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# Cache.Remove方法的具体用法?C# Cache.Remove怎么用?C# Cache.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cache
的用法示例。
在下文中一共展示了Cache.Remove方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanRemove
public void CanRemove()
{
var cache = new Cache<string, string>();
cache["Foo"] = "Bar";
cache.Remove("Foo").ShouldBe(true);
cache.ContainsKey("Foo").ShouldBe(false);
}
示例2: Insert
public void Insert(string key, object obj, double Minutes)
{
Cache cache = new Cache();
if (obj != null)
{
this.Response.Write(cache);
cache.Remove("dd");
cache.Insert(key, obj, null, DateTime.Now.AddMinutes(Minutes), Cache.NoSlidingExpiration, CacheItemPriority.High, (a,b,c) => { });
}
}
示例3: Cache_Remove_Item_Key_Should_Remove_Item
public void Cache_Remove_Item_Key_Should_Remove_Item()
{
Cache<string, int> cache = new Cache<string, int>();
bool EXPECTED = true;
cache.Add("1", 1);
Assert.AreEqual(EXPECTED, cache.Remove("1"));
int EXPECTEDCOUNT = 0;
Assert.AreEqual(EXPECTEDCOUNT, cache.Count);
EXPECTED = false;
Assert.AreEqual(EXPECTED, cache.Contains("1"));
}
示例4: TestCache
/// <exception cref="System.Exception"></exception>
public virtual void TestCache()
{
int retainCount = 1;
Cache cache = new Cache<string, Document>(retainCount);
IDictionary<string, object> props = new Dictionary<string, object>();
props.Put("foo", "bar");
Document doc1 = CreateDocumentWithProperties(database, props);
cache.Put(doc1.GetId(), doc1);
IDictionary<string, object> props2 = new Dictionary<string, object>();
props2.Put("foo2", "bar2");
Document doc2 = CreateDocumentWithProperties(database, props2);
cache.Put(doc2.GetId(), doc2);
NUnit.Framework.Assert.IsNotNull(cache.Get(doc1.GetId()));
NUnit.Framework.Assert.IsNotNull(cache.Get(doc2.GetId()));
cache.Remove(doc1.GetId());
NUnit.Framework.Assert.IsNull(cache.Get(doc1.GetId()));
cache.Clear();
NUnit.Framework.Assert.IsNull(cache.Get(doc2.GetId()));
}
示例5: ClearCache
private void ClearCache()
{
// clear the cache store.
Cache<X509Certificate2Collection> cache = new Cache<X509Certificate2Collection>(TestCacheName);
foreach (string domain in m_domains)
{
cache.Remove(domain);
}
}
示例6: Remove_ShouldDoNothingIfAbsent_Test
public void Remove_ShouldDoNothingIfAbsent_Test()
{
Cache cache = new Cache();
cache.Remove(TestKey);
Assert.IsNull(cache.Get<string, string>(TestKey));
}
示例7: Remove_ShouldDoNothingIfNull_Test
public void Remove_ShouldDoNothingIfNull_Test()
{
Cache cache = new Cache();
cache.Add(TestKey, TestValue, new TimeSpan(0, 0, 1));
Assert.AreEqual(TestValue, cache.Get<string, string>(TestKey));
cache.Remove<string>(null);
Assert.AreEqual(TestValue, cache.Get<string, string>(TestKey));
}
示例8: Remove_ShouldRemoveIfPresent_Test
public void Remove_ShouldRemoveIfPresent_Test()
{
Cache cache = new Cache();
cache.Add(TestKey, TestValue, new TimeSpan(0, 0, 1));
Assert.AreEqual(TestValue, cache.Get<string, string>(TestKey));
cache.Remove(TestKey);
Assert.IsNull(cache.Get<string, string>(TestKey));
}