本文整理汇总了C#中ICacheProvider.BuildCache方法的典型用法代码示例。如果您正苦于以下问题:C# ICacheProvider.BuildCache方法的具体用法?C# ICacheProvider.BuildCache怎么用?C# ICacheProvider.BuildCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICacheProvider
的用法示例。
在下文中一共展示了ICacheProvider.BuildCache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StandardQueryCache
public StandardQueryCache( ICacheProvider provider, IDictionary props, UpdateTimestampsCache updateTimestampsCache, string regionName )
{
if( regionName == null )
{
regionName = typeof( StandardQueryCache ).FullName;
}
log.Info( "starting query cache at region: " + regionName );
this.queryCache = provider.BuildCache( regionName, props );
this.updateTimestampsCache = updateTimestampsCache;
this.regionName = regionName;
}
示例2: DoTestCache
public void DoTestCache(ICacheProvider cacheProvider)
{
ICache cache = cacheProvider.BuildCache(typeof(String).FullName, new Dictionary<string, string>());
long longBefore = Timestamper.Next();
Thread.Sleep(15);
long before = Timestamper.Next();
Thread.Sleep(15);
ICacheConcurrencyStrategy ccs = new ReadWriteCache();
ccs.Cache = cache;
// cache something
CacheKey fooKey = CreateCacheKey("foo");
Assert.IsTrue(ccs.Put(fooKey, "foo", before, null, null, false));
Thread.Sleep(15);
long after = Timestamper.Next();
Assert.IsNull(ccs.Get(fooKey, longBefore));
Assert.AreEqual("foo", ccs.Get(fooKey, after));
Assert.IsFalse(ccs.Put(fooKey, "foo", before, null, null, false));
// update it;
ISoftLock fooLock = ccs.Lock(fooKey, null);
Assert.IsNull(ccs.Get(fooKey, after));
Assert.IsNull(ccs.Get(fooKey, longBefore));
Assert.IsFalse(ccs.Put(fooKey, "foo", before, null, null, false));
Thread.Sleep(15);
long whileLocked = Timestamper.Next();
Assert.IsFalse(ccs.Put(fooKey, "foo", whileLocked, null, null, false));
Thread.Sleep(15);
ccs.Release(fooKey, fooLock);
Assert.IsNull(ccs.Get(fooKey, after));
Assert.IsNull(ccs.Get(fooKey, longBefore));
Assert.IsFalse(ccs.Put(fooKey, "bar", whileLocked, null, null, false));
Assert.IsFalse(ccs.Put(fooKey, "bar", after, null, null, false));
Thread.Sleep(15);
long longAfter = Timestamper.Next();
Assert.IsTrue(ccs.Put(fooKey, "baz", longAfter, null, null, false));
Assert.IsNull(ccs.Get(fooKey, after));
Assert.IsNull(ccs.Get(fooKey, whileLocked));
Thread.Sleep(15);
long longLongAfter = Timestamper.Next();
Assert.AreEqual("baz", ccs.Get(fooKey, longLongAfter));
// update it again, with multiple locks
ISoftLock fooLock1 = ccs.Lock(fooKey, null);
ISoftLock fooLock2 = ccs.Lock(fooKey, null);
Assert.IsNull(ccs.Get(fooKey, longLongAfter));
Thread.Sleep(15);
whileLocked = Timestamper.Next();
Assert.IsFalse(ccs.Put(fooKey, "foo", whileLocked, null, null, false));
Thread.Sleep(15);
ccs.Release(fooKey, fooLock2);
Thread.Sleep(15);
long betweenReleases = Timestamper.Next();
Assert.IsFalse(ccs.Put(fooKey, "bar", betweenReleases, null, null, false));
Assert.IsNull(ccs.Get(fooKey, betweenReleases));
Thread.Sleep(15);
ccs.Release(fooKey, fooLock1);
Assert.IsFalse(ccs.Put(fooKey, "bar", whileLocked, null, null, false));
Thread.Sleep(15);
longAfter = Timestamper.Next();
Assert.IsTrue(ccs.Put(fooKey, "baz", longAfter, null, null, false));
//.........这里部分代码省略.........
示例3: UpdateTimestampsCache
public UpdateTimestampsCache( ICacheProvider provider, IDictionary props )
{
log.Info( "starting update timestamps cache at region: " + RegionName );
this.updateTimestamps = provider.BuildCache( RegionName, props );
}