Пример #1
0
 /// <summary>
 /// SPOP http://redis.io/commands/spop
 /// </summary>
 public Task <RedisResult <T> > Pop(CommandFlags commandFlags = CommandFlags.None)
 {
     return(TraceHelper.RecordReceive(Settings, Key, CallType, async() =>
     {
         var v = await Command.SetPopAsync(Key, commandFlags).ForAwait();
         long size;
         var result = RedisResult.FromRedisValue <T>(v, Settings, out size);
         return Tracing.CreateReceived(result, size);
     }));
 }
Пример #2
0
        /// <summary>
        /// GET http://redis.io/commands/get
        /// </summary>
        public Task <RedisResult <object> > Get(Type valueType, CommandFlags commandFlags = CommandFlags.None)
        {
            return(TraceHelper.RecordReceive(Settings, Key, CallType, async() =>
            {
                var value = await Command.StringGetAsync(Key, commandFlags).ForAwait();

                var size = 0L;
                var result = RedisResult.FromRedisValue(value, valueType, Settings, out size);
                return Tracing.CreateReceived(result, size);
            }));
        }
Пример #3
0
        /// <summary>
        /// LINDEX http://redis.io/commands/lindex
        /// </summary>
        public Task <RedisResult <T> > GetByIndex(long index, CommandFlags commandFlags = CommandFlags.None)
        {
            return(TraceHelper.RecordSendAndReceive(Settings, Key, CallType, async() =>
            {
                var value = await Command.ListGetByIndexAsync(Key, index, commandFlags).ForAwait();
                long valueSize;
                var result = RedisResult.FromRedisValue <T>(value, Settings, out valueSize);

                return Tracing.CreateSentAndReceived(new { index }, sizeof(long), result, valueSize);
            }));
        }
Пример #4
0
        /// <summary>
        /// HGET http://redis.io/commands/hget
        /// </summary>
        public Task <RedisResult <TValue> > Get(TKey field, CommandFlags commandFlags = CommandFlags.None)
        {
            return(TraceHelper.RecordSendAndReceive(Settings, Key, CallType, async() =>
            {
                long keySize;
                var rKey = Settings.ValueConverter.Serialize(field, out keySize);

                var rValue = await Command.HashGetAsync(Key, rKey, commandFlags).ForAwait();

                long valueSize;
                var value = RedisResult.FromRedisValue <TValue>(rValue, Settings, out valueSize);

                return Tracing.CreateSentAndReceived(new { field }, keySize, value, valueSize);
            }));
        }
Пример #5
0
        /// <summary>
        /// EVALSHA http://redis.io/commands/evalsha
        /// </summary>
        public Task <RedisResult <T> > ScriptEvaluate <T>(string script, RedisKey[] keys = null, RedisValue[] values = null, CommandFlags flags = CommandFlags.None)
        {
            return(TraceHelper.RecordSendAndReceive(Settings, Key, CallType, async() =>
            {
                var redisResult = await Command.ScriptEvaluateAsync(script, keys, values, flags).ForAwait();

                RedisResult <T> r;
                long receivedSize;
                if (redisResult.IsNull)
                {
                    receivedSize = 0;
                    r = RedisResult <T> .NoValue;
                }
                else
                {
                    var result = (RedisValue)redisResult;
                    r = RedisResult.FromRedisValue <T>(result, Settings, out receivedSize);
                }

                // script size is unknown but it's cached SHA.
                return Tracing.CreateSentAndReceived(new { script, keys, values }, 40, r, receivedSize);
            }));
        }