/// <summary>
        ///     初始化数据库环境、实例化子类中,所有Set属性
        /// </summary>
        public void Initializer()
        {
            if (IsInitializer)
            {
                return;
            }
            _client       = new RedisClient(_redisConnection);
            IsInitializer = true;

            Connection  = new RedisConnection(_client);
            Hash        = new RedisHash(_client);
            Key         = new RedisKey(_client);
            List        = new RedisList(_client);
            PubSub      = new RedisPubSub(_client);
            Script      = new RedisScript(_client);
            Server      = new RedisServer(_client);
            Set         = new RedisSet(_client);
            SortedSet   = new RedisSortedSet(_client);
            String      = new RedisString(_client);
            Transaction = new RedisTransaction(_client);
            Bit         = new RedisBit(_client);
            Expire      = new RedisExpire(_client);
            Sort        = new RedisSort(_client);
            Number      = new RedisNumber(_client);
        }
        /// <summary>
        ///     初始化数据库环境、实例化子类中,所有Set属性
        /// </summary>
        public void Initializer()
        {
            if (IsInitializer) { return; }
            _client = new RedisClient(_redisConnection);
            IsInitializer = true;

            Connection = new RedisConnection(_client);
            Hash = new RedisHash(_client);
            Key = new RedisKey(_client);
            List = new RedisList(_client);
            PubSub = new RedisPubSub(_client);
            Script = new RedisScript(_client);
            Server = new RedisServer(_client);
            Set = new RedisSet(_client);
            SortedSet = new RedisSortedSet(_client);
            String = new RedisString(_client);
            Transaction = new RedisTransaction(_client);
            Bit = new RedisBit(_client);
            Expire = new RedisExpire(_client);
            Sort = new RedisSort(_client);
            Number = new RedisNumber(_client);
        }
Example #3
0
 /// <summary>
 /// 返回保存给定列表、集合、有序集合 key 中经过排序的元素数量。
 /// </summary>
 /// <param name="client">Redis 客户端。</param>
 /// <param name="key">键名。</param>
 /// <param name="destination">目标键名。</param>
 /// <param name="by">按其元素来排序。</param>
 /// <param name="offset">指定要跳过的元素数量。</param>
 /// <param name="count">指定跳过 <paramref name="offset"/> 个指定的元素之后,要返回多少个对象。</param>
 /// <param name="sort">排序方式。</param>
 /// <param name="alpha">表示对字符串进行排序。</param>
 /// <param name="get">根据排序的结果来取出相应的键值列表。</param>
 /// <returns>保存列表形式的排序结果的元素数量。</returns>
 public static long SortStore(this IRedisClient client
     , string key, string destination, string by = null
     , long? offset = null, long? count = null
     , RedisSort? sort = null
     , bool? alpha = null
     , params string[] get)
 {
     List<string> args = new List<string>();
     args.Add(key);
     if(by != null)
         args.AddRange(new[] { "BY", by });
     if(offset.HasValue && count.HasValue)
         args.AddRange(new[] { "LIMIT", offset.Value.ToString(), count.Value.ToString() });
     foreach(var pattern in get)
         args.AddRange(new[] { "GET", pattern });
     if(sort.HasValue)
         args.Add(sort.ToString().ToUpperInvariant());
     if(alpha.HasValue && alpha.Value)
         args.Add("ALPHA");
     args.AddRange(new[] { "STORE", destination });
     return client.Execute(new RedisInteger("SORT", args.ToArray()));
 }