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")));
		}
		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();
		}
		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));
		}
		public NamespacedCacheKey(CacheKeyPrefix prefix, CacheKey namespaceCacheKey, params string[] keyParts)
			: base(prefix, GetParts(new CacheKey[] { namespaceCacheKey }, keyParts))
		{

		}
		public NamespacedCacheKey(CacheKeyPrefix prefix, CacheKey[] namespaceCacheKeys, params string[] keyParts)
			: base(prefix, GetParts(namespaceCacheKeys, keyParts))
		{

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