public void TestDirectoryCacheBasicOperations()
        {
            string cacheDirPath = Path.Combine(Path.GetTempPath(), "cachetest_" + DateTime.Now.Ticks);
            ICache cache = new DirectoryCache(cacheDirPath, 2000, new LruCacheEvictionPolicy());
            RunCacheTests(cache);
            ICache reopenedCache = new DirectoryCache(cacheDirPath, 2000, new LruCacheEvictionPolicy());
            var byteArray = cache.Lookup("ByteArray");
            Assert.IsNotNull(byteArray);
            Assert.AreEqual(4, byteArray.Length);
            for (int i = 0; i < 4; i++) Assert.AreEqual(i, byteArray[i]);

            var cachedString = cache.Lookup<string>("String");
            Assert.IsNotNull(cachedString);
            Assert.AreEqual("Hello World", cachedString);
            Assert.IsFalse(reopenedCache.ContainsKey("Object"));           
        }
 private static ICache GetQueryCache()
 {
     if (EnableQueryCache == false)
     {
         return new NullCache();
     }
     var cacheDir = QueryCacheDirectory;
     if (String.IsNullOrEmpty(cacheDir) && (!String.IsNullOrEmpty(StoreLocation)))
     {
         cacheDir = Path.Combine(StoreLocation, "_bscache");
     }
     if (!String.IsNullOrEmpty(cacheDir))
     {
         if (!Directory.Exists(cacheDir))
         {
             Directory.CreateDirectory(cacheDir);
         }
         ICache directoryCache = new DirectoryCache(cacheDir, MegabytesToBytes*QueryCacheDiskSpace,
                                                    new LruCacheEvictionPolicy()),
                memoryCache = new MemoryCache(MegabytesToBytes*QueryCacheMemory, new LruCacheEvictionPolicy());
         return new TwoLevelCache(memoryCache, directoryCache);
     }
     else
     {
         ICache memoryCache = new MemoryCache(MegabytesToBytes*QueryCacheMemory, new LruCacheEvictionPolicy());
         return memoryCache;
     }
 }