Esempio n. 1
0
        static ExecCmdListenResult ExecCmdListen(Action <ExecCmdListenResult, string> ondata, string cmd, string subcmd = null, params object[] parms)
        {
            var args = PrepareCmd(cmd, subcmd, parms);
            var rds  = RedisSocket.GetRedisSocket();

            Resp3Helper.Write(rds.Stream, args, true);
            var rd = Resp3Helper.Read <string>(rds.Stream);
            var rt = new ExecCmdListenResult {
                rds = rds
            };

            new Thread(() =>
            {
                ondata?.Invoke(rt, rd.Value);
                while (rt._running)
                {
                    try
                    {
                        ondata?.Invoke(rt, Resp3Helper.Read <string>(rds.Stream).Value);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }).Start();
            return(rt);
        }
Esempio n. 2
0
        static Resp3Helper.ReadResult <T> ExecCmd <T>(string cmd, string subcmd = null, params object[] parms)
        {
            var args = PrepareCmd(cmd, subcmd, parms);

            using (var rds = RedisSocket.GetRedisSocket())
            {
                Resp3Helper.Write(rds.Stream, args, true);
                var rt = Resp3Helper.Read <T>(rds.Stream);
                return(rt);
            }
        }