public RedisCacheManager(IRedisConnectionFactory connectionFactory) { _connection = connectionFactory.GetConnection(); _cacheSettings = connectionFactory.CacheSettings; _database = _connection.GetDatabase(); this._lock = new object(); }
public async Task <Note> GetNote(string id) { var dbContext = _factory.GetConnection().GetDatabase(); var exists = await dbContext.KeyExistsAsync(id); if (exists) { var tran = dbContext.CreateTransaction(); var getResult = tran.StringGetAsync(id); var delete = tran.KeyDeleteAsync(id); await tran.ExecuteAsync(); var message = (string)getResult.Result; return(new Note(new Guid(id)) { Message = message }); } return(null); }
public RedisCacheStore(RedisConfiguration configuration, IRedisConnectionFactory connectionFactory, IJsonSerializer serializer) { // TODO: (core) Build versionStr from SmartstoreVersion class var versionStr = "5.0.0"; // Don't try to deserialize values created with older app versions (could be incompatible) _cachePrefix = "cache." + versionStr + ":"; _keyPrefix = BuildCacheKey(""); _configuration = configuration; _connectionFactory = connectionFactory; _multiplexer = _connectionFactory.GetConnection(configuration.ConnectionStrings.Cache ?? configuration.ConnectionStrings.Default); _messageBus = _connectionFactory.GetMessageBus(configuration.ConnectionStrings.Bus ?? configuration.ConnectionStrings.Default); _serializer = serializer; // Subscribe to key events triggered by Redis on item expiration _messageBus.SubscribeToKeyEvent("expired", OnRedisKeyEvent, false); _messageBus.SubscribeToKeyEvent("evicted", OnRedisKeyEvent, false); }
public RedisService(IConfiguration configuration, IRedisConnectionFactory redisConnection) { _redisDb = redisConnection.GetConnection().GetDatabase(); this._configuration = configuration; this.expireHour = Convert.ToInt32(this._configuration["RedisCache:ExpireHour"]); }