本文整理汇总了C#中LruCache.TryGetValue方法的典型用法代码示例。如果您正苦于以下问题:C# LruCache.TryGetValue方法的具体用法?C# LruCache.TryGetValue怎么用?C# LruCache.TryGetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LruCache
的用法示例。
在下文中一共展示了LruCache.TryGetValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestLruCacheTryGetValue
public void TestLruCacheTryGetValue()
{
RegionEndpoint regionEndpoint;
var lru = new LruCache<string, RegionEndpoint>(5);
lru.AddOrUpdate("my-bucket-us-east-1", RegionEndpoint.USEast1);
lru.AddOrUpdate("my-bucket-us-west-2", RegionEndpoint.USWest2);
lru.AddOrUpdate("my-bucket-ap-northeast-2", RegionEndpoint.APNortheast2);
lru.AddOrUpdate("my-bucket-sa-east-1", RegionEndpoint.SAEast1);
lru.TryGetValue("my-bucket-us-west-2", out regionEndpoint);
Assert.AreEqual(RegionEndpoint.USWest2, regionEndpoint);
lru.TryGetValue("my-bucket-ap-northeast-2", out regionEndpoint);
Assert.AreEqual(RegionEndpoint.APNortheast2, regionEndpoint);
}
示例2: AssertInCache
private void AssertInCache(LruCache<string, string> cache, string key, string expectedValue)
{
string value = null;
Assert.IsTrue(cache.TryGetValue(key, out value));
Assert.AreEqual(expectedValue, value);
}
示例3: AssertNotInCache
private void AssertNotInCache(LruCache<string, string> cache, string key)
{
string value = null;
Assert.IsFalse(cache.TryGetValue(key, out value));
Assert.IsNull(value);
}
示例4: TryGetValue_KeyExists_ValuePopulated
public void TryGetValue_KeyExists_ValuePopulated()
{
var lru = new LruCache<string, string>(1);
lru.Add("k1", "v1");
string value;
lru.TryGetValue("k1", out value);
Assert.AreEqual("v1", value);
}
示例5: TryGetValue_KeyExists_HitCountIncreased
public void TryGetValue_KeyExists_HitCountIncreased()
{
var lru = new LruCache<string, string>(1);
lru.Add("k1", "v1");
Assert.AreEqual(0, lru.HitCount);
string value;
lru.TryGetValue("k1", out value);
Assert.AreEqual(1, lru.HitCount);
}
示例6: TryGetValue_KeyDoesNotExist_MissCountIncreased
public void TryGetValue_KeyDoesNotExist_MissCountIncreased()
{
var lru = new LruCache<string, string>(1);
Assert.AreEqual(0, lru.MissCount);
string value = null;
lru.TryGetValue("k1", out value);
Assert.AreEqual(1, lru.MissCount);
}
示例7: TryGetValue_KeyDoesNotExist_DefaultValuePopulated
public void TryGetValue_KeyDoesNotExist_DefaultValuePopulated()
{
var lru = new LruCache<string, string>(1);
string value = null;
lru.TryGetValue("k1", out value);
Assert.IsNull(value);
}