func (this *RedisClient) Lrange(key string, start, stop int) (val []string, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return nil, err
	}
	val, err = c.Cmd("LRANGE", key, start, stop).List()
	this._pool.Put(c)
	return
}
}}}
{{{ Lrange key start stop
package lib
import (
	"errors"
	"fmt"
	"github.com/mediocregopher/radix.v2/pool"
	"github.com/mediocregopher/radix.v2/redis"
	"strconv"
	"sync"
	"time"
)
var Redis = &RedisProxy{c: map[string]*RedisClient{}}
func NewRedis(conf_name string) (*RedisClient, error) {  
	config := Conf.GetAll(conf_name)
	if 0 == len(config) {
		return nil, errors.New("Redis 资源不存在:" + conf_name)
	}
	return Redis.get(config)
}  
func NewRedisClient(config map[string]string) (*RedisClient, error) {  
	return Redis.get(config)
}  
type RedisProxy struct {
	mutex sync.RWMutex
	c     map[string]*RedisClient
}
func (this *RedisProxy) get(config map[string]string) (*RedisClient, error) {  
	host := config["host"]
	this.mutex.RLock()
	if this.c[host] == nil {
		this.mutex.RUnlock()
		this.mutex.Lock()
		defer this.mutex.Unlock()
		if this.c[host] == nil {
			timeout, _ := strconv.Atoi(config["timeout"])
			poolsize, _ := strconv.Atoi(config["poolsize"])
			rc := &RedisClient{
				Host:     host,
				Password: config["password"],
				Timeout:  timeout,
				Poolsize: poolsize,
			}
			err := rc.Init()
			if nil != err {
				fmt.Println("add redis error:", "[", host, "] :", err)
				return nil, err
			}
			this.c[host] = rc
			fmt.Println("add redis :", "[", host, "]")
		}
	} else {
		this.mutex.RUnlock()
	}
	return this.c[host], nil
}  
type RedisClient struct {
	Host     string
	Password string
	Timeout  int
	Poolsize int
	network  string
	_pool    *pool.Pool
}
func (this *RedisClient) Init() error {
	var err error
	if "" == this.network {
		this.network = "tcp"
	}
	if 0 == this.Poolsize {
		this.Poolsize = 10
	}
	if 0 == this.Timeout {
		this.Timeout = 3
	}
	_dialfuc := func(network, addr string) (*redis.Client, error) {
		client, err := redis.DialTimeout(network, addr, time.Second*time.Duration(this.Timeout))
		if err != nil {
			return nil, err
		}
		if "" != this.Password {
			if err = client.Cmd("AUTH", this.Password).Err; err != nil {
				client.Close()
				return nil, err
			}
		}
		return client, nil
	}
	this._pool, err = pool.NewCustom(this.network, this.Host, this.Poolsize, _dialfuc)
	if err != nil {
		return err
	}
	return nil
}
func (this *RedisClient) Set(key string, val interface{}) error {
	c, err := this._pool.Get()
	if err != nil {
		return err
	}
	err = c.Cmd("SET", key, val).Err
	this._pool.Put(c)
	return err
}
func (this *RedisClient) Setex(key string, secs int, val interface{}) error {
	c, err := this._pool.Get()
	if err != nil {
		return err
	}
	err = c.Cmd("SETEX", key, secs, val).Err
	this._pool.Put(c)
	return err
}
func (this *RedisClient) Expire(key string, expire int) error {
	c, err := this._pool.Get()
	if err != nil {
		return err
	}
	err = c.Cmd("EXPIRE", key, expire).Err
	this._pool.Put(c)
	return err
}
func (this *RedisClient) Exists(key string) (bool, error) {
	c, err := this._pool.Get()
	if err != nil {
		return false, err
	}
	val := 0
	val, err = c.Cmd("Exists", key).Int()
	this._pool.Put(c)
	return val == 1, nil
}  
func (this *RedisClient) Ttl(key string) (int, error) {
	c, err := this._pool.Get()
	if err != nil {
		return 0, err
	}
	val := 0
	val, err = c.Cmd("Ttl", key).Int()
	this._pool.Put(c)
	return val, nil
}  
func (this *RedisClient) Incr(key string) (val int, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("INCR", key).Int()
	this._pool.Put(c)
	return
}  
func (this *RedisClient) Incrby(key string, increment int) (val int, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("INCRBY", key, increment).Int()
	this._pool.Put(c)
	return
}  
func (this *RedisClient) IncrbyFloat(key string, increment interface{}) (val float64, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("INCRBYFLOAT", key, increment).Float64()
	this._pool.Put(c)
	return
}  
func (this *RedisClient) Decr(key string) (val int, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("DECR", key).Int()
	this._pool.Put(c)
	return
}  
func (this *RedisClient) Decrby(key string, increment int) (val int, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("DECRBY", key, increment).Int()
	this._pool.Put(c)
	return
}  
func (this *RedisClient) Get(key string) (val string, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("GET", key).Str()
	this._pool.Put(c)
	return
}
func (this *RedisClient) Del(key string) (err error) {
	c, err := this._pool.Get()
	if err != nil {
		return err
	}
	err = c.Cmd("DEL", key).Err
	this._pool.Put(c)
	return err
}  
func (this *RedisClient) DelAll(keys []string) (err error) {
	c, err := this._pool.Get()
	if err != nil {
		return err
	}
	err = c.Cmd("DEL", keys).Err
	this._pool.Put(c)
	return err
}  
func (this *RedisClient) ExpireAt(key string, timestamp int) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	_ = c.Cmd("EXPIREAT", key, timestamp).Err
	this._pool.Put(c)
}  
func (this *RedisClient) Keys(key string) (val []string, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return nil, err
	}
	val, err = c.Cmd("KEYS", key).List()
	this._pool.Put(c)
	return
}  
func (this *RedisClient) Scan(cursor, pattern, count string) (val []string, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return nil, err
	}
	val, err = c.Cmd("SCAN", cursor, "MATCH", pattern, "COUNT", count).List()
	this._pool.Put(c)
	return
}  
func (this *RedisClient) Rpush(key string, val interface{}) error {
	c, err := this._pool.Get()
	if err != nil {
		return err
	}
	err = c.Cmd("Rpush", key, val).Err
	this._pool.Put(c)
	return err
}
func (this *RedisClient) Lpush(key string, val interface{}) error {
	c, err := this._pool.Get()
	if err != nil {
		return err
	}
	err = c.Cmd("Lpush", key, val).Err
	this._pool.Put(c)
	return err
}
func (this *RedisClient) Rpop(key string) (val string, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("Rpop", key).Str()
	this._pool.Put(c)
	return
}
func (this *RedisClient) Lpop(key string) (val string, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("Lpop", key).Str()
	this._pool.Put(c)
	return
}
func (this *RedisClient) Brpop(key string, timeout int) (val []string, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("BRpop", key, timeout).List()
	this._pool.Put(c)
	return
}
func (this *RedisClient) Blpop(key string, timeout int) (val []string, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("BLpop", key, timeout).List()
	this._pool.Put(c)
	return
}
func (this *RedisClient) Llen(key string) (val int, err error) {
	c, err := this._pool.Get()
	if err != nil {
		return
	}
	val, err = c.Cmd("Llen", key).Int()
	this._pool.Put(c)
	return
}