Пример #1
0
        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);
            }
        }