コード例 #1
0
		public void TestThatGettingANamespacedKeySetsTheMissingNamespaceKeyValues()
		{
			Caching.Instances.Main.FlushAll();
			CacheKey[] namespaceKeys = new CacheKey[] { new CacheKey(CacheKeyPrefix.TagVersion, "1") };
			Assert.IsNull(Caching.Instances.Main.Get(namespaceKeys[0]));
			CacheKey key = new NamespacedCacheKey(Caching.CacheKeyPrefix.BobCacheItem, namespaceKeys, "2");
			Assert.IsNotNull(Caching.Instances.Main.Get(new CacheKey(CacheKeyPrefix.TagVersion, "1")));
		}
コード例 #2
0
		private static string[] GetParts(CacheKey[] namespaceCacheKeys, string[] keyParts)
		{
			List<string> returnList = new List<string>();
			string[] versionKeys = namespaceCacheKeys.ConvertAll(key => key.ToString());
			Getter<string>[] getters = new Getter<string>[namespaceCacheKeys.Length];
			getters.Length.Times(i => getters[i] = () => Guid.NewGuid().ToString());
			string[] versionValues = Caching.Instances.Main.MultiGet<string>(versionKeys, getters, DateTime.MaxValue);
			returnList.AddRange(versionValues);
			returnList.AddRange(keyParts);
			return returnList.ToArray();
		}
コード例 #3
0
		public void TestThatSettingANamespaceKeyClearsTheNamespacedKeyValue()
		{
			Caching.Instances.Main.FlushAll();
			CacheKey[] namespaceKeys = new CacheKey[] { new CacheKey(CacheKeyPrefix.TagVersion, "1") };
			CacheKey key = new NamespacedCacheKey(Caching.CacheKeyPrefix.BobCacheItem, namespaceKeys, "2");
			Caching.Instances.Main.Store(key, "hello");
			Assert.AreEqual("hello", Caching.Instances.Main.Get(key));
			Caching.Instances.Main.Set(namespaceKeys[0].ToString(), Guid.NewGuid().ToString());
			key = new NamespacedCacheKey(Caching.CacheKeyPrefix.BobCacheItem, namespaceKeys, "2");
			Assert.IsNull(Caching.Instances.Main.Get(key));
		}
コード例 #4
0
		public NamespacedCacheKey(CacheKeyPrefix prefix, CacheKey namespaceCacheKey, params string[] keyParts)
			: base(prefix, GetParts(new CacheKey[] { namespaceCacheKey }, keyParts))
		{

		}
コード例 #5
0
		public NamespacedCacheKey(CacheKeyPrefix prefix, CacheKey[] namespaceCacheKeys, params string[] keyParts)
			: base(prefix, GetParts(namespaceCacheKeys, keyParts))
		{

		}
コード例 #6
0
		public static uint GetCounter(this ICounterStore counterStore, CacheKey key, Cache.Create<uint> create)
		{
			return counterStore.GetCounter(key.ToString(), create);
		}
コード例 #7
0
		public static uint Increment(this ICounterStore counterStore, CacheKey cacheKey, Cache.Create<uint> create)
		{
			return counterStore.Increment(cacheKey.ToString(), create);
		}