public override T2 AdapaterCall <T1, T2>(CommandPacket cmd, Func <RedisResult <T1>, T2> parse)
 {
     return(_cli.LogCall(cmd, () =>
     {
         _redisSocket.Write(cmd);
         var rt = cmd.Read <T1>();
         rt.IsErrorThrow = _cli._isThrowRedisSimpleError;
         return parse(rt);
     }));
 }
Ejemplo n.º 2
0
 public override T2 AdapaterCall <T1, T2>(CommandPacket cmd, Func <RedisResult <T1>, T2> parse)
 {
     TryMulti();
     return(_cli.LogCall(cmd, () =>
     {
         _redisSocket.Write(cmd);
         cmd.Read <T1>().ThrowOrValue();
         cmd._readed = false; //exec 还需要再读一次
         _commands.Add(new TransactionCommand
         {
             Command = cmd,
             Parse = obj => parse(new RedisResult <T1>(obj.ConvertTo <T1>(), null, true, RedisMessageType.SimpleString)
             {
                 Encoding = _redisSocket.Encoding
             })
         });
         return default(T2);
     }));
 }
Ejemplo n.º 3
0
 internal void Call(CommandPacket cmd)
 {
     _topOwner.LogCall <object>(cmd, () =>
     {
         if (IsSubscribed == false)
         {
             throw new RedisClientException($"Subscription not opened, unable to execute");
         }
         lock (_lock)
             _redisSocket.Write(cmd);
         return(null);
     });
 }
Ejemplo n.º 4
0
 internal void Call(CommandPacket cmd)
 {
     _topOwner.LogCall <object>(cmd, () =>
     {
         if (_redisSocket != null)
         {
             lock (_lock)
                 if (_redisSocket != null)
                 {
                     _redisSocket.Write(cmd);
                 }
         }
         if (_redisSocket == null)
         {
             throw new Exception($"Subscription not opened, unable to execute");
         }
         return(null);
     });
 }
Ejemplo n.º 5
0
            public object[] EndPipe()
            {
                if (_commands.Any() == false)
                {
                    return(new object[0]);
                }

                try
                {
                    switch (UseType)
                    {
                    case UseType.Pooling: break;

                    case UseType.Cluster: return(ClusterEndPipe());

                    case UseType.Sentinel:
                    case UseType.SingleInside: break;

                    case UseType.SingleTemp: break;
                    }

                    CommandPacket epcmd = "EndPipe";
                    return(_cli.LogCall(epcmd, () =>
                    {
                        using (var rds = _cli._adapter.GetRedisSocket(null))
                        {
                            epcmd._redisSocket = rds;
                            EndPipe(rds, _commands);
                        }
                        return _commands.Select(a => a.Result).ToArray();
                    }));
                }
                finally
                {
                    _commands.Clear();
                }

                object[] ClusterEndPipe()
                {
                    throw new NotSupportedException();
                }
            }