Example #1
0
        public override void Overwrite <T>(String key, T value, TimeSpan slidingExpiration)
        {
            if (_config.Readonly)
            {
                throw new InvalidOperationException();
            }
            var cacheKey = BuildCacheKey(key);
            var db       = _connection.GetDatabase();

            db.StringSet(cacheKey, NewtonsoftJsonUtil.Stringify(value));
            db.KeyExpire(cacheKey, slidingExpiration);
        }
Example #2
0
 public override void Overwrite <T>(String key, T value)
 {
     if (_config.Readonly)
     {
         throw new InvalidOperationException();
     }
     if (_config.MaxExpiration.HasValue)
     {
         Overwrite(key, value, _config.MaxExpiration.Value);
     }
     else
     {
         var db = _connection.GetDatabase();
         db.StringSet(BuildCacheKey(key), NewtonsoftJsonUtil.Stringify(value));
     }
 }