Example #1
0
        public override string DoProcess(Request request)
        {
            var redisObject = store.Get(request.args[0]);
            var valToIncBy = long.Parse(request.args[1]);
            if (redisObject == null)
            {
                var redisString = new RedisString("0");
                long longValue;
                redisString.IncrementBy(valToIncBy, out longValue);
                store.Set(request.args[0], redisString);
                return Reply.IntgerReply(longValue);
            }
            if (!redisObject.IsRedisString())
            {
                return Reply.ErrWrongType();
            }

            var s = redisObject as RedisString;
            if(s.IsConvertibleToLong())
            {
                long longValue;
                var success = s.IncrementBy(valToIncBy, out longValue);
                return success ? Reply.IntgerReply(longValue) : Reply.OverFlow();
            }
            return Reply.ValueNotInt();
        }
Example #2
0
        public override string DoProcess(Request request)
        {
            var redisObject = store.Get(request.args[0]);

            if(redisObject == null)
            {
                var redisString = new RedisString(request.args[1]);
                store.Set(request.args[0],redisString);
                return Reply.IntgerReply(redisString.Length());
            }

            if (!redisObject.IsRedisString())
            {
                return Reply.ErrWrongType();
            }

            var s = redisObject as RedisString;
            s.Append(request.args[1]);
            return Reply.IntgerReply(s.Length());
        }