Ejemplo n.º 1
0
        private static string GetWriteResult(IRedisWriter redisWriter)
        {
            var buffers = redisWriter.FlushBuffers();
            var bytes   = buffers.SelectMany(buffer => buffer.ToArray()).ToArray();
            var result  = Encoding.UTF8.GetString(bytes);

            return(result);
        }
Ejemplo n.º 2
0
 public RedisPipeline(int pipelineId, IAsyncSocket socket, Stream stream, IRedisWriter redisWriter, IRedisReader redisReader, int socketTimeout = 60000)
 {
     _pipelineId    = pipelineId;
     _socket        = socket;
     _stream        = stream;
     _redisWriter   = redisWriter;
     _redisReader   = redisReader;
     _socketTimeout = socketTimeout;
 }
Ejemplo n.º 3
0
        public RedisClient(
            RedisClientConfig config,
            IRedisWriter <TKey, TItem> redisWriter,
            IRedisReader <TKey, TItem> redisReader,
            IRedisDeleter <TKey, TItem> redisDeleter)
        {
            _connectionString = string.IsNullOrEmpty(config?.ConnectionString) ? throw new ArgumentNullException(nameof(config.ConnectionString)) : config.ConnectionString;
            _redisWriter      = redisWriter ?? throw new ArgumentNullException(nameof(redisWriter));
            _redisReader      = redisReader ?? throw new ArgumentNullException(nameof(redisReader));
            _redisDeleter     = redisDeleter ?? throw new ArgumentNullException(nameof(redisDeleter));

            _keyPrefix = $"{typeof(TItem).Namespace}.{typeof(TItem).Name}::";
        }
Ejemplo n.º 4
0
        public virtual void WriteTo(IRedisWriter writer)
        {
            var argsLength = m_Arguments != null ? m_Arguments.Length : 0;

            writer.Write((byte)'*');
            writer.Write(argsLength + 1);
            writer.Write(RedisConstants.LineEnd);
            writer.Write((byte)'$');
            writer.Write(m_Command.Length);
            writer.Write(RedisConstants.LineEnd);
            writer.Write(m_Command);
            writer.Write(RedisConstants.LineEnd);

            if (argsLength > 0)
            {
                byte[] arg;
                for (var i = 0; i < argsLength; i++)
                {
                    arg = m_Arguments[i];

                    if (arg == null)
                    {
                        writer.Write(RedisConstants.NullBulkString);
                    }
                    else if (arg.Length == 0)
                    {
                        writer.Write(RedisConstants.EmptyBulkString);
                        writer.Write(RedisConstants.LineEnd);
                    }
                    else
                    {
                        writer.Write((byte)'$');
                        writer.Write(arg.Length);
                        writer.Write(RedisConstants.LineEnd);
                        writer.Write(arg);
                    }
                    writer.Write(RedisConstants.LineEnd);
                }
            }
        }
Ejemplo n.º 5
0
        static CacheHelper()
        {
            IApplicationContext ctx = ContextRegistry.GetContext();

            RedisWriter = ctx.GetObject("CacheWriterRedis_") as IRedisWriter;
        }