当前位置: 首页>>代码示例>>C#>>正文


C# ICacheProvider.BuildCache方法代码示例

本文整理汇总了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;
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:11,代码来源:StandardQueryCache.cs

示例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));
//.........这里部分代码省略.........
开发者ID:paulbatum,项目名称:nhibernate,代码行数:101,代码来源:CacheFixture.cs

示例3: UpdateTimestampsCache

		public UpdateTimestampsCache( ICacheProvider provider, IDictionary props )
		{
			log.Info( "starting update timestamps cache at region: " + RegionName );
			this.updateTimestamps = provider.BuildCache( RegionName, props );
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:5,代码来源:UpdateTimestampsCache.cs


注:本文中的ICacheProvider.BuildCache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。