Exemplo n.º 1
0
        public RedisBool ClientSetName(RedisParam connectionName)
        {
            if (connectionName.IsNull)
            {
                throw new ArgumentNullException("connectionName");
            }

            return(ExpectOK(RedisCommandList.Client, RedisCommandList.SetName, connectionName.ToBytes()));
        }
Exemplo n.º 2
0
        public RedisString HGetString(RedisParam key, RedisParam field)
        {
            if (key.IsNull)
            {
                throw new ArgumentNullException("key");
            }

            if (field.IsEmpty)
            {
                throw new ArgumentNullException("field");
            }

            return(ExpectBulkString(RedisCommandList.HGet, key, field.ToBytes()));
        }
Exemplo n.º 3
0
        public RedisString BRPopLPushString(RedisParam source, RedisParam destination)
        {
            if (source.IsNull)
            {
                throw new ArgumentNullException("source");
            }

            if (destination.IsNull)
            {
                throw new ArgumentNullException("destination");
            }

            return(ExpectBulkString(RedisCommandList.BRPopLPush, source.ToBytes(), destination.ToBytes()));
        }
Exemplo n.º 4
0
        public RedisBool Migrate(RedisParam host, int port, RedisParam key, int destinationDb, long timeoutMs, bool copy = false,
                                 bool replace = false, params RedisParam[] keys)
        {
            if (host.IsNull)
            {
                throw new ArgumentNullException("host");
            }

            if (key.IsEmpty)
            {
                throw new ArgumentNullException("key");
            }

            ValidateNotDisposed();

            var parameters = host.ToBytes()
                             .Join(port.ToBytes())
                             .Join(!key.IsNull ? key.Data : RedisCommandList.EmptyString)
                             .Join(destinationDb.ToBytes())
                             .Join(timeoutMs.ToBytes());

            if (copy)
            {
                parameters = parameters.Join(RedisCommandList.Copy);
            }

            if (replace)
            {
                parameters = parameters.Join(RedisCommandList.Replace);
            }

            if (keys.Length > 0)
            {
                parameters = parameters
                             .Join(RedisCommandList.Keys)
                             .Join(keys.ToBytesArray());
            }

            return(ExpectOK(RedisCommandList.Migrate, parameters));
        }
Exemplo n.º 5
0
        public RedisMultiString HMGetStrings(RedisParam key, RedisParam field, params RedisParam[] fields)
        {
            if (key.IsNull)
            {
                throw new ArgumentNullException("key");
            }

            if (field.IsEmpty)
            {
                throw new ArgumentNullException("field");
            }

            ValidateNotDisposed();

            if (fields.Length > 0)
            {
                var parameters = key
                                 .Join(field)
                                 .Join(fields);

                return(ExpectMultiDataStrings(RedisCommandList.HMGet, parameters));
            }
            return(ExpectMultiDataStrings(RedisCommandList.HMGet, key, field.ToBytes()));
        }
Exemplo n.º 6
0
        public RedisResult <IDictionary <string, string> > ConfigGet(RedisParam parameter)
        {
            if (parameter.IsNull)
            {
                throw new ArgumentNullException("parameter");
            }

            var lines = ExpectMultiDataStrings(RedisCommandList.Config, RedisCommandList.Get, parameter.ToBytes());

            if (lines != null)
            {
                var linesLength = lines.Length;
                if (lines.Length > 0)
                {
                    var result = new Dictionary <string, string>(linesLength / 2);
                    for (var i = 0; i < linesLength; i += 2)
                    {
                        var key = (lines[i] ?? String.Empty).Trim();
                        if (!key.IsEmpty())
                        {
                            result[key] = (lines[i + 1] ?? String.Empty).Trim();
                        }
                    }
                    return(new RedisResult <IDictionary <string, string> >(result));
                }
            }
            return(new RedisResult <IDictionary <string, string> >(null));
        }