Ejemplo n.º 1
0
    public static Dictionary <string, ceCasinoGameBaseEx> GetGameDictionary(long domainID
                                                                            , bool excludeDisabled          = true
                                                                            , bool excludeOperatorInvisible = true
                                                                            , bool allowCache = true)
    {
        string cacheKey = string.Format(GAME_CACHE_KEY_FORMAT, Constant.DomainGamesCachePrefix, domainID);

        cacheKey = string.Format("{0}{1}{2}dict", cacheKey, excludeDisabled, excludeOperatorInvisible);
        Dictionary <string, ceCasinoGameBaseEx> games = HttpRuntime.Cache[cacheKey] as Dictionary <string, ceCasinoGameBaseEx>;

        if (games != null && allowCache)
        {
            return(games);
        }

        List <ceCasinoGameBaseEx> allGames = GetGameList(domainID, excludeDisabled, excludeOperatorInvisible, allowCache);

        games = allGames.ToDictionary(g => g.ID.ToString(), g => g);

        foreach (ceCasinoGameBaseEx game in allGames.Where(g => !string.IsNullOrWhiteSpace(g.Slug)))
        {
            games.Add(game.Slug, game);
        }

        CacheManager.AddCache(cacheKey, games);
        return(games);
    }
Ejemplo n.º 2
0
    public static ceDomainConfigEx GetSysDomain()
    {
        ceDomainConfigEx domain = HttpRuntime.Cache[Constant.SysDomainCacheKey] as ceDomainConfigEx;

        if (domain != null)
        {
            return(domain);
        }

        lock (typeof(DomainManager))
        {
            domain = HttpRuntime.Cache[Constant.SysDomainCacheKey] as ceDomainConfigEx;
            if (domain != null)
            {
                return(domain);
            }

            DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
            domain = dca.GetSys();

            CacheManager.AddCache(Constant.SysDomainCacheKey, domain);
        }

        return(domain);
    }
Ejemplo n.º 3
0
        public void GetBasketWithExecuteFunctionWithRedirectTest()
        {
            const string cacheName = "AccessClient";
            const int    basketId  = 1;
            var          basket    = new ObjectWithAnId {
                Id = basketId
            };

            var cacheManager = new CacheManager();
            var cache        = new InMemoryTestCache(cacheName);

            cacheManager.AddCache(cache);

            var cacheKeyBasket = cacheManager.GetKey("GetBasket", basketId);

            //Act
            var cached = cacheManager.ExecuteFunction(cacheName, cacheKeyBasket, () => basket);

            // Assert
            Assert.AreSame(cached, basket);
            Assert.IsTrue(cacheManager.TryGet(cacheName, cacheKeyBasket, out cached));

            Assert.IsTrue(cache.TryGet("Basket1", out cached));
            Assert.AreSame(cached, basket);
        }
Ejemplo n.º 4
0
        public void FlushItemsByTagTest()
        {
            // Arrange
            const string cacheName = "AccessClient";

            var cacheManager = new CacheManager();
            var cache        = new InMemoryTestCache(cacheName);

            cacheManager.AddCache(cache);

            ObjectWithAnId ignore;
            int            i;

            // Act
            var key         = cacheManager.GetKey("GetSomethingWithFlush", 1);
            var somethingIn = new ObjectWithAnId {
                Id = 1
            };
            var somethingOut = cacheManager.ExecuteFunction(cacheName, key, "Tag" + 1, () => somethingIn);

            Assert.IsTrue(cacheManager.TryGet(cacheName, key, out ignore));

            key = cacheManager.GetKey("GetWhateverWithFlush", 1);
            const int whateverIn  = 1;
            var       whateverOut = cacheManager.ExecuteFunction(cacheName, key, "Tag" + 1, () => whateverIn);

            Assert.IsTrue(cacheManager.TryGet(cacheName, key, out i));

            key = cacheManager.GetKey("GetSomethingWithFlush", 2);
            var somethingIn2 = new ObjectWithAnId {
                Id = 2
            };
            var somethingOut2 = cacheManager.ExecuteFunction(cacheName, key, "Tag" + 2, () => somethingIn2);

            Assert.IsTrue(cacheManager.TryGet(cacheName, key, out ignore));

            // Assert 1
            Assert.AreSame(somethingIn, somethingOut);
            Assert.AreEqual(whateverIn, whateverOut);
            Assert.AreSame(somethingIn2, somethingOut2);

            // Act 2
            var updated = new ObjectWithAnId {
                Id = 1
            };

            cacheManager.Flush(cacheName, "Tag" + updated.Id);
            var updateKey = cacheManager.GetKey("GetSomethingWithFlush", updated.Id);

            cacheManager.Add(cacheName, updateKey, "Tag" + 1, updated);

            // Assert 2
            key = cacheManager.GetKey("GetWhateverWithFlush", 1);
            Assert.IsFalse(cacheManager.TryGet(cacheName, key, out i));
            key = cacheManager.GetKey("GetSomethingWithFlush", 1);
            Assert.IsTrue(cacheManager.TryGet(cacheName, key, out ignore));
            key = cacheManager.GetKey("GetSomethingWithFlush", 2);
            Assert.IsTrue(cacheManager.TryGet(cacheName, key, out ignore));
        }
Ejemplo n.º 5
0
        public void AddCache()
        {
            var c = new Customer("scott1", 10);

            CacheManager.AddCache("test1", c, ServiceLocator.Instance.GetService <AbsoluteTimeExpiration>("SCache"));

            var cachedCustomer = CacheManager.GetCache <Customer>("test1");

            Assert.IsNotNull(cachedCustomer);
            Assert.AreEqual(cachedCustomer.Name, "scott1");
        }
Ejemplo n.º 6
0
        public void GetBasketThenInsertWithCacheRefresh()
        {
            // Arrange
            const string cacheName = "AccessClient";
            const int    basketId  = 1;
            var          basket    = new ObjectWithAnId {
                Id = basketId
            };
            var checkout = new ObjectWithAnId {
                Id = basketId
            };

            var cacheManager = new CacheManager();
            var cache        = new InMemoryTestCache(cacheName);

            cacheManager.AddCache(cache);

            var cacheKeyBasket   = cacheManager.GetKey("GetBasket", basketId);
            var cacheKeyCheckout = cacheManager.GetKey("GetCheckout", basketId);

            //Act
            if (!cacheManager.HasConfiguration(cacheName))
            {
                Assert.Fail("Should have a cache config file");
            }
            var success = cacheManager.Add(cacheName, cacheKeyBasket, basket);

            Assert.IsTrue(success, "basket should be added.");

            success = cacheManager.Add(cacheName, cacheKeyCheckout, checkout);
            Assert.IsTrue(success, "Checkout should be added.");

            object cached;

            var cacheKeyInsertBasket = cacheManager.GetKey("InsertBasketItem", basket);

            success = cacheManager.TryGet(cacheName, cacheKeyInsertBasket, out cached);
            Assert.IsFalse(success, "Should not be there on that key.");

            var newBasket = new ObjectWithAnId {
                Id = basketId
            };

            success = cacheManager.Add(cacheName, cacheKeyInsertBasket, newBasket);
            Assert.IsTrue(success, "New basket should now be added on original key.");

            cacheManager.TryGet(cacheName, cacheKeyBasket, out cached);
            Assert.AreSame(newBasket, cached, "Now it should be cached.");

            cacheManager.TryGet(cacheName, cacheKeyCheckout, out cached);
            Assert.IsNull(cached, "Checkout should have been flushed");
        }
Ejemplo n.º 7
0
        private Dictionary <string, ceDomainConfigItem> GetCfgCache(long domainID)
        {
            string cacheKey = string.Format("{0}{1}", CACHE_KEY_PREFIX, this.DomainID);
            Dictionary <string, ceDomainConfigItem> items = HttpRuntime.Cache[cacheKey] as Dictionary <string, ceDomainConfigItem>;

            if (items == null)
            {
                DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
                items = dca.GetConfigurationItemsByDomainID(domainID);
                CacheManager.AddCache(cacheKey, items);
            }
            return(items);
        }
Ejemplo n.º 8
0
        public void CacheConfigDurationWhenNoFileTest()
        {
            // Arrange
            const string cacheName = "CacheWithNoFile";

            var cacheManager = new CacheManager();
            var cache        = new InMemoryTestCache(cacheName);

            cacheManager.AddCache(cache);

            //Assert
            Assert.AreEqual(null, CacheConfiguration.Instance(cacheName).DefaultDuration, "Default duration");
            Assert.AreEqual(0, CacheConfiguration.Instance(cacheName).GetCacheTime("WhatEver"));
        }
Ejemplo n.º 9
0
    public static Dictionary <string, ceLiveCasinoTableBaseEx> GetLiveCasinoTableDictionary(long domainID)
    {
        string cacheKey = string.Format(GAME_CACHE_KEY_FORMAT, Constant.DomainLiveCasinoTableCachePrefix, domainID);
        Dictionary <string, ceLiveCasinoTableBaseEx> tables = HttpRuntime.Cache[cacheKey] as Dictionary <string, ceLiveCasinoTableBaseEx>;

        if (tables != null)
        {
            return(tables);
        }

        List <ceLiveCasinoTableBaseEx> allTables = LiveCasinoTableAccessor.GetDomainTables(domainID, null, true);

        tables = allTables.ToDictionary(t => t.ID.ToString(), t => t);
        CacheManager.AddCache(cacheKey, tables);
        return(tables);
    }
Ejemplo n.º 10
0
        public void CacheConfigDurationTest()
        {
            // Arrange
            const string cacheName = "AccessClient";

            var cacheManager = new CacheManager();
            var cache        = new InMemoryTestCache(cacheName);

            cacheManager.AddCache(cache);

            //Assert
            Assert.AreEqual(5, CacheConfiguration.Instance(cacheName).DefaultDuration, "Default duration");
            Assert.AreEqual(5, CacheConfiguration.Instance(cacheName).GetCacheTime("GetEntityWithDefaultDuration"), "Item with defafult duration");
            Assert.AreEqual(1, CacheConfiguration.Instance(cacheName).GetCacheTime("GetEntityWith1MinuteDuration"), "Item 1 min duration");
            Assert.AreEqual(0, CacheConfiguration.Instance(cacheName).GetCacheTime("GetEntityWithZeroDuration"), "Item 0 duration");
            Assert.AreEqual(0, CacheConfiguration.Instance(cacheName).GetCacheTime("NonExistingItem"), "Non-existing 0 duration");
        }
Ejemplo n.º 11
0
    public static Dictionary <int, ceCasinoVendor> GetVendorDictionary(long domainID)
    {
        string cacheKey = string.Format(GAME_CACHE_KEY_FORMAT, Constant.DomainVendorsCachePrefix, domainID);
        Dictionary <int, ceCasinoVendor> vendors = HttpRuntime.Cache[cacheKey] as Dictionary <int, ceCasinoVendor>;

        if (vendors != null)
        {
            return(vendors);
        }

        CasinoVendorAccessor  cva             = CasinoVendorAccessor.CreateInstance <CasinoVendorAccessor>();
        List <ceCasinoVendor> ceCasinoVendors = cva.GetEnabledVendorList(DomainManager.CurrentDomainID, Constant.SystemDomainID);

        vendors = ceCasinoVendors.ToDictionary(v => v.VendorID, v => v);

        CacheManager.AddCache(cacheKey, vendors);
        return(vendors);
    }
Ejemplo n.º 12
0
    /// <summary>
    /// 判断加载完成
    /// </summary>
    void LoadUpdate()
    {
        if (www.isDone)
        {
            isFree  = true;
            enabled = false;
            if (www.error != null)
            {
                Debug.LogWarning("error : url " + req.url + " \n error:" + www.error);
                DispatchErrorEvent(req);
            }
            else
            {
                if (OnProcess != null)
                {
                    OnProcess(this, 1);
                }
                //Debug.Log("will complete : url " + req.url + " \n key:" + req.key);
                try
                {
                    CacheData cacheData = new CacheData(www, www.assetBundle, req.key);//缓存
                    CacheManager.AddCache(cacheData);

                    IList <CRequest> depens = null;
                    if (m_AssetBundleManifest != null)
                    {
                        string[] deps = m_AssetBundleManifest.GetAllDependencies(req.assetBundleName);
                        depens = GetDependencies(deps);
                        int[] alldepens = GetDependenciesHashCode(deps);
                        cacheData.allDependencies = alldepens;
                    }
                    else if (m_AssetBundleManifest == null)
                    {
                        Debug.LogWarning(req.key + "Please initialize AssetBundleManifest");
                    }
                    this.DispatchCompleteEvent(this.req, depens);
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
            }
        }
    }
Ejemplo n.º 13
0
        public void GetBasketWithExecuteFunctionWithRedirectAndClearTest()
        {
            const string cacheName = "AccessClient";
            const int    basketId  = 1;
            var          basket    = new ObjectWithAnId {
                Id = basketId
            };
            var checkout = new ObjectWithAnId {
                Id = basketId
            };

            var cacheManager = new CacheManager();
            var cache        = new InMemoryTestCache(cacheName);

            cacheManager.AddCache(cache);

            var cacheKeyBasket   = cacheManager.GetKey("GetBasket", basketId);
            var cacheKeyCheckout = cacheManager.GetKey("GetCheckout", basketId);

            //Act
            var cachedCheckout = cacheManager.ExecuteFunction(cacheName, cacheKeyCheckout, () => checkout);
            var cachedBasket   = cacheManager.ExecuteFunction(cacheName, cacheKeyBasket, () => basket);

            // Assert
            Assert.AreSame(cachedBasket, basket);
            Assert.IsTrue(cacheManager.TryGet(cacheName, cacheKeyBasket, out cachedBasket));
            Assert.AreSame(cachedCheckout, checkout);
            Assert.IsTrue(cacheManager.TryGet(cacheName, cacheKeyCheckout, out cachedCheckout));

            // Act 2
            var modifiedBasket = new ObjectWithAnId {
                Id = basketId
            };
            var cacheKeyInsert = cacheManager.GetKey("InsertBasketItem", modifiedBasket.Id);

            cacheManager.Add(cacheName, cacheKeyInsert, modifiedBasket);

            // Assert 2
            Assert.IsFalse(cacheManager.TryGet(cacheName, cacheKeyCheckout, out cachedCheckout));
            Assert.IsTrue(cacheManager.TryGet(cacheName, cacheKeyBasket, out cachedBasket));
            Assert.AreSame(cachedBasket, modifiedBasket);
        }
Ejemplo n.º 14
0
    public static List <ceCasinoGameBaseEx> GetGameList(long domainID
                                                        , bool excludeDisabled          = true
                                                        , bool excludeOperatorInvisible = true
                                                        , bool allowCache = true)
    {
        string cacheKey = string.Format(GAME_CACHE_KEY_FORMAT, Constant.DomainGamesCachePrefix, domainID);

        cacheKey = string.Format("{0}{1}{2}list", cacheKey, excludeDisabled, excludeOperatorInvisible);
        List <ceCasinoGameBaseEx> games = HttpRuntime.Cache[cacheKey] as List <ceCasinoGameBaseEx>;

        if (games != null && allowCache)
        {
            return(games);
        }

        games = CasinoGameAccessor.GetDomainGames(domainID, excludeDisabled, excludeOperatorInvisible);

        CacheManager.AddCache(cacheKey, games);
        return(games);
    }
Ejemplo n.º 15
0
        public void GetCustomerThenUpdateWithRefreshFormatTest()
        {
            // Arrange
            const string cacheName        = "AccessClient";
            const int    customerId       = 1;
            var          existingCustomer = new ObjectWithAnIdAndData {
                Id = customerId, Data = "Data1"
            };

            var cacheManager = new CacheManager();
            var cache        = new InMemoryTestCache(cacheName);

            cacheManager.AddCache(cache);

            //Act
            var cacheKeyCustomer = cacheManager.GetKey("GetCustomer", customerId);

            if (!cacheManager.HasConfiguration(cacheName))
            {
                Assert.Fail("Should have a cache config file");
            }
            var success = cacheManager.Add(cacheName, cacheKeyCustomer, existingCustomer);

            Assert.IsTrue(success, "customer should be added.");

            object cached;

            var cacheKeyUpdateCustomer = cacheManager.GetKey("UpdateCustomer2", customerId);

            success = cacheManager.TryGet(cacheName, cacheKeyUpdateCustomer, out cached);
            Assert.IsFalse(success, "Should not be there on that key.");

            var updatedCustomer = new ObjectWithAnIdAndData {
                Id = customerId, Data = "Data2"
            };

            success = cacheManager.Add(cacheName, cacheKeyUpdateCustomer, updatedCustomer);
            Assert.IsTrue(success, "Updated customer should now have replaced original key");
            success = cacheManager.TryGet(cacheName, cacheKeyCustomer, out cached);
            Assert.AreSame(updatedCustomer, cached, "Should be the same in the cache after update");
        }
Ejemplo n.º 16
0
        public void FlushItemsByMultipleDependencyNamesTest()
        {
            // Arrange
            const string cacheName = "AccessClient";

            var cacheManager = new CacheManager();
            var cache        = new InMemoryTestCache(cacheName);

            cacheManager.AddCache(cache);

            int i;

            // Act
            var dependency1 = new [] { "Customer1" };
            var dependency2 = new[] { "Customer1", "Company1", "Pricelist1" };

            var dependency3 = new[] { "Customer2" };
            var dependency4 = new[] { "Customer2", "Company2", "Pricelist2" };

            cacheManager.ExecuteFunction(cacheName, cacheManager.GetKey("GetSomethingWithFlush", 1), dependency1, () => 1);
            cacheManager.ExecuteFunction(cacheName, cacheManager.GetKey("GetWhateverWithFlush", 1), dependency2, () => 2);
            cacheManager.ExecuteFunction(cacheName, cacheManager.GetKey("GetSomethingWithFlush", 2), dependency3, () => 3);
            cacheManager.ExecuteFunction(cacheName, cacheManager.GetKey("GetWhateverWithFlush", 2), dependency4, () => 4);

            // Assert 1 All in cache
            Assert.IsTrue(cacheManager.TryGet(cacheName, cacheManager.GetKey("GetSomethingWithFlush", 1), out i));
            Assert.IsTrue(cacheManager.TryGet(cacheName, cacheManager.GetKey("GetWhateverWithFlush", 1), out i));
            Assert.IsTrue(cacheManager.TryGet(cacheName, cacheManager.GetKey("GetSomethingWithFlush", 2), out i));
            Assert.IsTrue(cacheManager.TryGet(cacheName, cacheManager.GetKey("GetWhateverWithFlush", 2), out i));

            // Act 2
            cacheManager.Flush(cacheName, "Customer1");
            cacheManager.Flush(cacheName, "Pricelist2");

            // Assert 2 Just item 3 in cache
            Assert.IsFalse(cacheManager.TryGet(cacheName, cacheManager.GetKey("GetSomethingWithFlush", 1), out i));
            Assert.IsFalse(cacheManager.TryGet(cacheName, cacheManager.GetKey("GetWhateverWithFlush", 1), out i));
            Assert.IsTrue(cacheManager.TryGet(cacheName, cacheManager.GetKey("GetSomethingWithFlush", 2), out i));
            Assert.IsFalse(cacheManager.TryGet(cacheName, cacheManager.GetKey("GetWhateverWithFlush", 2), out i));
        }
Ejemplo n.º 17
0
        public void GetNullDataAndThenFlushItToCreateNew()
        {
            // Arrange
            const string cacheName = "AccessClient";
            const string email     = "*****@*****.**";
            var          newObject = new ObjectWithAnId {
                Id = 1
            };

            var cacheManager = new CacheManager();
            var cache        = new InMemoryTestCache(cacheName);

            cacheManager.AddCache(cache);

            var cacheKey = cacheManager.GetKey("GetCustomerByEmail", email);

            //Act
            if (!cacheManager.HasConfiguration(cacheName))
            {
                Assert.Fail("Should have a cache config file");
            }
            var added = cacheManager.Add(cacheName, cacheKey, (ObjectWithAnId)null);

            Assert.IsFalse(added, "Should not be added.");

            object cached;

            cacheKey = cacheManager.GetKey("CreateCustomer", newObject);
            cacheManager.TryGet(cacheName, cacheKey, out cached);
            Assert.IsNull(cached, "Should not have value in cache");

            added = cacheManager.Add(cacheName, cacheKey, newObject);
            Assert.IsFalse(added, "Should not add creates.");

            cacheKey = cacheManager.GetKey("GetCustomerByEmail", email);
            cacheManager.Add(cacheName, cacheKey, newObject);
            cacheManager.TryGet(cacheName, cacheKey, out cached);
            Assert.AreSame(newObject, cached, "Now it should be cached.");
        }
Ejemplo n.º 18
0
        public void AddCache_AbsoluteExpiration()
        {
            var c          = new Customer("scott1", 10);
            var expiration = ServiceLocator.Instance.GetService <AbsoluteTimeExpiration>("S1Cache");

            CacheManager.AddCache("test1", c, expiration);

            //todo:暂时没有找到好的方法进行单元测试
            //实际在debug的时候确实会过期,但是如果使用sleep运行的
            //话就不会过期

            //int i = 0;
            //while (i++ < 10)
            //{
            //    Customer cachedCustomer = BDDD.Cache.CacheManager.GetCache<Customer>("test1");

            //    Console.WriteLine(DateTime.Now.ToString());
            //    Assert.IsNotNull(cachedCustomer);
            //    Assert.AreEqual<string>(cachedCustomer.Name, "scott1");

            //    Thread.Sleep(1000);
            //}
        }
Ejemplo n.º 19
0
    public static List <DomainVendorConfig> GetDomainVendors()
    {
        List <DomainVendorConfig> domainVendors = HttpRuntime.Cache[Constant.DomainVendorCacheKey] as List <DomainVendorConfig>;

        if (domainVendors != null)
        {
            return(domainVendors);
        }

        lock (typeof(DomainManager))
        {
            domainVendors = HttpRuntime.Cache[Constant.DomainVendorCacheKey] as List <DomainVendorConfig>;
            if (domainVendors != null)
            {
                return(domainVendors);
            }

            DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
            domainVendors = dca.GetEnabledVendorsForAllOperators(Constant.SystemDomainID);

            CacheManager.AddCache(Constant.DomainVendorCacheKey, domainVendors);
        }
        return(domainVendors);
    }
Ejemplo n.º 20
0
    public static List <ceDomainConfigEx> GetDomains()
    {
        List <ceDomainConfigEx> domains = HttpRuntime.Cache[Constant.DomainCacheKey] as List <ceDomainConfigEx>;

        if (domains != null)
        {
            return(ObjectHelper.DeepClone(domains));
        }

        lock (typeof(DomainManager))
        {
            domains = HttpRuntime.Cache[Constant.DomainCacheKey] as List <ceDomainConfigEx>;
            if (domains != null)
            {
                return(domains);
            }

            DomainConfigAccessor dca = DomainConfigAccessor.CreateInstance <DomainConfigAccessor>();
            domains = dca.GetAll(ActiveStatus.Active);

            CacheManager.AddCache(Constant.DomainCacheKey, domains);
        }
        return(domains);
    }
Ejemplo n.º 21
0
        public ContentResult GameList(string apiUsername
                                      , string tags
                                      , string categories
                                      , string platforms
                                      , string vendors
                                      , string ids
                                      , string slugs
                                      , string countryCode
                                      , bool?includeMoreFields
                                      , bool allowCache = true
                                      , int gameType    = 0
                                      )
        {
            if (string.IsNullOrWhiteSpace(apiUsername))
            {
                return(WrapResponse(ResultCode.Error_InvalidParameter, string.Format("Operator [{0}] is NULL!", apiUsername)));
            }

            var domains = DomainManager.GetApiUsername_DomainDictionary();
            ceDomainConfigEx domain;

            if (!domains.TryGetValue(apiUsername.Trim(), out domain))
            {
                return(WrapResponse(ResultCode.Error_InvalidParameter, "Operator is invalid!"));
            }

            if (!IsWhitelistedIPAddress(domain, Request.GetRealUserAddress()))
            {
                return(WrapResponse(ResultCode.Error_BlockedIPAddress, string.Format("IP Address [{0}] is denied!", Request.GetRealUserAddress())));
            }

            DomainManager.CurrentDomainID = domain.DomainID;
            try
            {
                if (!includeMoreFields.HasValue)
                {
                    includeMoreFields = false;
                }

                string cacheKey = string.Format(GAME_LIST_CACHE_KEY_FORMAT
                                                , Constant.GameListCachePrefix
                                                , domain.DomainID
                                                , tags
                                                , categories
                                                , platforms
                                                , vendors
                                                , ids
                                                , includeMoreFields.Value
                                                , slugs
                                                );
                StringBuilderCache cache = HttpRuntime.Cache[cacheKey] as StringBuilderCache;
                if (cache == null || cache.IsExpried || !allowCache)
                {
                    //List<ceCasinoGameBaseEx> games = CasinoGameAccessor.GetDomainGames(domain.DomainID, true, true);
                    List <ceCasinoGameBaseEx> games = CacheManager.GetGameList(domain.DomainID, true, true, allowCache);

                    if (!string.IsNullOrWhiteSpace(vendors))
                    {
                        List <string> filteredVendors = vendors.Split(',')
                                                        .Where(c => !string.IsNullOrWhiteSpace(c))
                                                        .Select(c => c.Trim().ToUpperInvariant())
                                                        .ToList();
                        games = games.Where(g => filteredVendors.Contains(g.VendorID.ToString(), StringComparer.InvariantCultureIgnoreCase))
                                .ToList();
                    }

                    if (!string.IsNullOrWhiteSpace(ids))
                    {
                        List <long> filteredIDs = ids.Split(',')
                                                  .Where(c => Regex.IsMatch(c, @"^\d+$", RegexOptions.Compiled))
                                                  .Select(c => long.Parse(c))
                                                  .ToList();
                        games = games.Where(g => filteredIDs.Contains(g.ID))
                                .ToList();
                    }

                    if (!string.IsNullOrWhiteSpace(slugs))
                    {
                        List <string> filteredSlugs = slugs.Split(',').ToList();
                        games = games.Where(g => !string.IsNullOrEmpty(g.Slug) && filteredSlugs.Contains(g.Slug))
                                .ToList();
                    }

                    if (!string.IsNullOrWhiteSpace(categories))
                    {
                        games = games.Where(g => HasIntersection(categories, g.GameCategories)).ToList();
                    }

                    if (!string.IsNullOrWhiteSpace(tags))
                    {
                        games = games.Where(g => HasIntersection(tags, g.Tags)).ToList();
                    }

                    if (!string.IsNullOrWhiteSpace(platforms))
                    {
                        games = games.Where(g => HasIntersection(platforms, g.ClientCompatibility)).ToList();
                    }

                    StringBuilder sb = GetGameListXml(domain, games, includeMoreFields.Value, allowCache, gameType);
                    cache = new StringBuilderCache(sb, 36000);
                    CacheManager.AddCache(cacheKey, cache);
                }

                return(WrapResponse(ResultCode.Success, string.Empty, cache.Value));
            }
            catch (Exception ex)
            {
                Logger.Exception(ex);
                return(WrapResponse(ResultCode.Error_SystemFailure, ex.Message));
            }
        }
        public void AddCacheTest()
        {
            var result = CacheManager.AddCache("test", new LocalCache("test"));

            Assert.AreEqual(result, true);
        }