Пример #1
0
        public object Any(SetCacheProviderRequest request)
        {
            try
            {
                switch (request.provider)
                {
                    case "memcache":
                        var memcache = new MemcachedClientCache();
                        AppHost.Instance.Container.Register<ICacheClient>(memcache);
                        return new HttpResult("Cache Provider switched to MemCache.");

                    case "redis":
                        AppHost.Instance.Container.Register<ICacheClient>(c => c.Resolve<IRedisClientsManager>().GetCacheClient());
                        return new HttpResult("Cache Provider switched to Redis.");

                    case "aws":
                        var aws = new DynamoDbCacheClient("", "", Amazon.RegionEndpoint.APSoutheast1);
                        AppHost.Instance.Container.Register<ICacheClient>(aws);
                        return new HttpResult("Cache Provider switched to Amazon Web Service DynamoDb Cache Client.");

                    case "azure":
                        AppHost.Instance.Container.Register<ICacheClient>(new AzureCacheClient("default"));
                        return new HttpResult("Cache Provider switched to Microsoft Azure Cache Client.");

                    default:
                        AppHost.Instance.Container.Register<ICacheClient>(new MemoryCacheClient());
                        return new HttpResult("Cache Provider switched to In-Memory Cache Client.");
                }
            }
            catch
            {
                throw;
            }
        }
        public object Any(SetCacheProviderRequest request)
        {
            try
            {
                switch (request.provider)
                {
                case "memcache":
                    var memcache = new MemcachedClientCache();
                    AppHost.Instance.Container.Register <ICacheClient>(memcache);
                    return(new HttpResult("Cache Provider switched to MemCache."));

                case "redis":
                    AppHost.Instance.Container.Register <ICacheClient>(c => c.Resolve <IRedisClientsManager>().GetCacheClient());
                    return(new HttpResult("Cache Provider switched to Redis."));

                case "aws":
                    var aws = new DynamoDbCacheClient("", "", Amazon.RegionEndpoint.APSoutheast1);
                    AppHost.Instance.Container.Register <ICacheClient>(aws);
                    return(new HttpResult("Cache Provider switched to Amazon Web Service DynamoDb Cache Client."));

                case "azure":
                    AppHost.Instance.Container.Register <ICacheClient>(new AzureCacheClient("default"));
                    return(new HttpResult("Cache Provider switched to Microsoft Azure Cache Client."));

                default:
                    AppHost.Instance.Container.Register <ICacheClient>(new MemoryCacheClient());
                    return(new HttpResult("Cache Provider switched to In-Memory Cache Client."));
                }
            }
            catch
            {
                throw;
            }
        }