public void KeyRename() { IRedis redis = ServiceStackRedis.Default; var key = Guid.NewGuid().ToString(); var value = Guid.NewGuid().ToString(); redis.StringSet(key, value); Assert.IsTrue(redis.KeyExists(key)); var key2 = Guid.NewGuid().ToString(); var renamed1 = redis.KeyRename(key, key2); Assert.IsTrue(renamed1); Assert.IsFalse(redis.KeyExists(key)); Assert.IsTrue(redis.KeyExists(key2)); redis.KeyDelete(key2); try { var renamed12 = redis.KeyRename(key, key2); Assert.Fail(); } catch (Exception ex) { Assert.IsTrue(ex is RedisException); } }
public void StringTest() { var cacheKey = Guid.NewGuid().ToString(); IRedis redis = ServiceStackRedis.Default; //StringGet var cacheField = redis.StringGet(cacheKey); Assert.IsFalse(cacheField.HasValue); Assert.AreEqual((String)cacheField, null); //StringSet var cacheValue = Guid.NewGuid().ToString(); redis.StringSet(cacheKey, cacheValue); //StringGet again cacheField = redis.StringGet(cacheKey); Assert.IsTrue(cacheField.HasValue); Assert.AreEqual((String)cacheField, cacheValue); //KeyDelete redis.KeyDelete(cacheKey); }
public override void Overwrite <T>(String key, T value) { _redis.StringSet(BuildCacheKey(key), NewtonsoftJsonUtil.Stringify(value)); }