Beispiel #1
0
        public bool HMSet(string key, IEnumerable <KeyValuePair <string, string> > keyValuePairs)
        {
            int len = 0;

            foreach (KeyValuePair <string, string> node in keyValuePairs)
            {
                if (!this.IsValidField(node.Key) || !this.IsValidValue(node.Value))
                {
                    return(false);
                }
                len++;
            }
            if (len == 0)
            {
                return(false);
            }

            RedisNativeClient client = this.pool.GetRedisClient(key);

            if (client == null)
            {
                return(false);
            }

            var keys   = new byte[len][];
            var values = new byte[len][];
            int i      = 0;

            foreach (KeyValuePair <string, string> node in keyValuePairs)
            {
                keys[i]   = UTF8String.ToBytes(node.Key);
                values[i] = UTF8String.ToBytes(node.Value);
            }

            client.HMSet(key, keys, values);
            return(true);
        }