public RedisCache(ICachingConfigure cachingConfigure) : base(cachingConfigure) { var configureOptions = new ConfigurationOptions() { Password = cachingConfigure.ConfigureDetail.DefaultValue("password"), AbortOnConnectFail = cachingConfigure.ConfigureDetail.GetKeyAndConvertTo("abortConnect", StringToBoolConvertor.Instance), AllowAdmin = cachingConfigure.ConfigureDetail.GetKeyAndConvertTo("allowAdmin", StringToBoolConvertor.Instance), ChannelPrefix = cachingConfigure.ConfigureDetail.DefaultValue("channelPrefix"), ConnectRetry = cachingConfigure.ConfigureDetail.GetKeyAndConvertTo("connectRetry", StringToInt32Conventor.Instance), ConnectTimeout = cachingConfigure.ConfigureDetail.GetKeyAndConvertTo("connectTimeout", StringToInt32Conventor.Instance), ConfigurationChannel = cachingConfigure.ConfigureDetail.DefaultValue("configChannel"), DefaultDatabase = cachingConfigure.ConfigureDetail.GetKeyAndConvertTo("defaultDatabase", StringToInt32Conventor.Instance), KeepAlive = cachingConfigure.ConfigureDetail.GetKeyAndConvertTo("keepAlive", StringToInt32Conventor.Instance), SyncTimeout = 15000, AsyncTimeout = 15000, Proxy = Proxy.None, ResolveDns = cachingConfigure.ConfigureDetail.GetKeyAndConvertTo("resolveDns", StringToBoolConvertor.Instance), Ssl = cachingConfigure.ConfigureDetail.GetKeyAndConvertTo("ssl", StringToBoolConvertor.Instance), }; cachingConfigure.ConfigureDetail.DefaultValue("end-points").Split(';').ToList().ForEach(x => configureOptions.EndPoints.Add(x)); connection = ConnectionMultiplexer.Connect(configureOptions); server = connection.GetServer(connection.GetEndPoints()[0]); database = connection.GetDatabase(); }
public LocalMemoryCache(ICachingConfigure cachingConfigure) : base(cachingConfigure) { var maxObjects = cachingConfigure.ConfigureDetail.GetKeyAndConvertTo("max-objects", StringToInt32Conventor.Instance); var maxConcurrency = cachingConfigure.ConfigureDetail.GetKeyAndConvertTo("max-concurrency", StringToInt32Conventor.Instance); expireInMiniSeconds = cachingConfigure.ExpireInMiniSeconds; memory = new ConcurrentDictionary <string, CacheModel>(maxConcurrency, maxObjects); Task.Run(() => { var keys = memory.Keys.ToList(); foreach (var item in keys) { if (memory.ContainsKey(item) && memory.TryGetValue(item, out var model) && IsExpire(model)) { memory.TryRemove(item, out var cacheModel); } } Thread.Sleep(expireInMiniSeconds); }); }
public RedisConfigureTests() { IStorage storage = StorageFactory.Factory.GetLocalStorage(ConstVariable.ApplicationPath); redisConfigure = CacheConfigureFactory.Factory.CreateConfigure(storage, "MockData/Core/Configure/RedisConfigure.json"); }
public MemoryCached(ICachingConfigure cachingConfigure) : base(cachingConfigure) { }
protected CommonCache(ICachingConfigure cachingConfigure) { this.cachingConfigure = cachingConfigure; }