/// <summary> /// Creates <see cref="RedisDistributedCacheStore"/> from <see cref="CacheStoreDefinition"/> configuration /// </summary> /// <param name="cacheStoreInfo">Redis <see cref="CacheStoreDefinition"/> configuration</param> /// <returns><see cref="CustomDistributedCacheStore"/> object</returns> public ICacheStore CreateCacheStore(CacheStoreDefinition cacheStoreInfo) { ICacheStore cacheStore = null; if (!string.IsNullOrWhiteSpace(cacheStoreInfo.StoreConfig)) { //CustomStoreInfo sqlServerStoreInfo = // JsonConvert.DeserializeObject<CustomStoreInfo>(cacheStoreInfo.CacheOptions); //cacheStore = new CustomDistributedCacheStore<T>(Type.GetType(cacheStoreInfo.TypeInfo)) //{ // CacheOptions = options => // { // options.ConnectionString = sqlServerStoreInfo.ConnectionString; // options.DefaultSlidingExpiration = sqlServerStoreInfo.DefaultSlidingExpiration; // options.ExpiredItemsDeletionInterval = sqlServerStoreInfo.ExpiredItemsDeletionInterval; // options.SchemaName = sqlServerStoreInfo.SchemaName; // options.TableName = sqlServerStoreInfo.TableName; // } //}; } else { //cacheStore = new CustomDistributedCacheStore<Type>() { CacheOptions = options => { } }; } return(cacheStore); }
/// <summary> /// Creates <see cref="MySqlDistributedCacheStore"/> from <see cref="CacheStoreDefinition"/> /// </summary> /// <param name="cacheStoreInfo">MySQL <see cref="CacheStoreDefinition"/> configuration</param> /// <returns><see cref="MySqlDistributedCacheStore"/> object</returns> public ICacheStore CreateCacheStore(CacheStoreDefinition cacheStoreInfo) { ISerializer serializer = !string.IsNullOrWhiteSpace(cacheStoreInfo.SerializerType) ? _serviceProvider.GetService(Type.GetType(cacheStoreInfo.SerializerType)) as ISerializer : null; return(new MySqlDistributedCacheStore(serializer) { CacheOptions = !string.IsNullOrWhiteSpace(cacheStoreInfo.StoreConfig) ? JsonConvert.DeserializeObject <MySqlCacheOptions>(cacheStoreInfo.StoreConfig) : new MySqlCacheOptions() }); }