func (c *commandable) SetNX(key string, value interface{}, expiration time.Duration) *BoolCmd {
	var cmd *BoolCmd
	if expiration == 0 {
		cmd = NewBoolCmd("SETNX", key, value)
	} else {
		if usePrecise(expiration) {
			cmd = NewBoolCmd("SET", key, value, "PX", formatMs(expiration), "NX")
		} else {
			cmd = NewBoolCmd("SET", key, value, "EX", formatSec(expiration), "NX")
		}
	}
	c.Process(cmd)
	return cmd
}
Redis `SET key value [expiration] NX` command.

Zero expiration means the key has no expiration time.
package redis
import (
	"io"
	"log"
	"strconv"
	"time"
)
func formatInt(i int64) string {
	return strconv.FormatInt(i, 10)
}
func formatUint(i uint64) string {
	return strconv.FormatUint(i, 10)
}
func formatFloat(f float64) string {
	return strconv.FormatFloat(f, 'f', -1, 64)
}
func readTimeout(timeout time.Duration) time.Duration {
	if timeout == 0 {
		return 0
	}
	return timeout + time.Second
}
func usePrecise(dur time.Duration) bool {
	return dur < time.Second || dur%time.Second != 0
}
func formatMs(dur time.Duration) string {
	if dur > 0 && dur < time.Millisecond {
		log.Printf(
			"redis: specified duration is %s, but minimal supported value is %s",
			dur, time.Millisecond,
		)
	}
	return formatInt(int64(dur / time.Millisecond))
}
func formatSec(dur time.Duration) string {
	if dur > 0 && dur < time.Second {
		log.Printf(
			"redis: specified duration is %s, but minimal supported value is %s",
			dur, time.Second,
		)
	}
	return formatInt(int64(dur / time.Second))
}
type commandable struct {
	process func(cmd Cmder)
}
func (c *commandable) Process(cmd Cmder) {
	c.process(cmd)
}
func (c *commandable) Auth(password string) *StatusCmd {
	cmd := newKeylessStatusCmd("AUTH", password)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Echo(message string) *StringCmd {
	cmd := NewStringCmd("ECHO", message)
	cmd._clusterKeyPos = 0
	c.Process(cmd)
	return cmd
}
func (c *commandable) Ping() *StatusCmd {
	cmd := newKeylessStatusCmd("PING")
	c.Process(cmd)
	return cmd
}
func (c *commandable) Quit() *StatusCmd {
	panic("not implemented")
}
func (c *commandable) Select(index int64) *StatusCmd {
	cmd := newKeylessStatusCmd("SELECT", formatInt(index))
	c.Process(cmd)
	return cmd
}
func (c *commandable) Del(keys ...string) *IntCmd {
	args := make([]interface{}, 1+len(keys))
	args[0] = "DEL"
	for i, key := range keys {
		args[1+i] = key
	}
	cmd := NewIntCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Dump(key string) *StringCmd {
	cmd := NewStringCmd("DUMP", key)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Exists(key string) *BoolCmd {
	cmd := NewBoolCmd("EXISTS", key)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Expire(key string, expiration time.Duration) *BoolCmd {
	cmd := NewBoolCmd("EXPIRE", key, formatSec(expiration))
	c.Process(cmd)
	return cmd
}
func (c *commandable) ExpireAt(key string, tm time.Time) *BoolCmd {
	cmd := NewBoolCmd("EXPIREAT", key, formatInt(tm.Unix()))
	c.Process(cmd)
	return cmd
}
func (c *commandable) Keys(pattern string) *StringSliceCmd {
	cmd := NewStringSliceCmd("KEYS", pattern)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Migrate(host, port, key string, db int64, timeout time.Duration) *StatusCmd {
	cmd := NewStatusCmd(
		"MIGRATE",
		host,
		port,
		key,
		formatInt(db),
		formatMs(timeout),
	)
	cmd._clusterKeyPos = 3
	cmd.setReadTimeout(readTimeout(timeout))
	c.Process(cmd)
	return cmd
}
func (c *commandable) Move(key string, db int64) *BoolCmd {
	cmd := NewBoolCmd("MOVE", key, formatInt(db))
	c.Process(cmd)
	return cmd
}
func (c *commandable) ObjectRefCount(keys ...string) *IntCmd {
	args := make([]interface{}, 2+len(keys))
	args[0] = "OBJECT"
	args[1] = "REFCOUNT"
	for i, key := range keys {
		args[2+i] = key
	}
	cmd := NewIntCmd(args...)
	cmd._clusterKeyPos = 2
	c.Process(cmd)
	return cmd
}
func (c *commandable) ObjectEncoding(keys ...string) *StringCmd {
	args := make([]interface{}, 2+len(keys))
	args[0] = "OBJECT"
	args[1] = "ENCODING"
	for i, key := range keys {
		args[2+i] = key
	}
	cmd := NewStringCmd(args...)
	cmd._clusterKeyPos = 2
	c.Process(cmd)
	return cmd
}
func (c *commandable) ObjectIdleTime(keys ...string) *DurationCmd {
	args := make([]interface{}, 2+len(keys))
	args[0] = "OBJECT"
	args[1] = "IDLETIME"
	for i, key := range keys {
		args[2+i] = key
	}
	cmd := NewDurationCmd(time.Second, args...)
	cmd._clusterKeyPos = 2
	c.Process(cmd)
	return cmd
}
func (c *commandable) Persist(key string) *BoolCmd {
	cmd := NewBoolCmd("PERSIST", key)
	c.Process(cmd)
	return cmd
}
func (c *commandable) PExpire(key string, expiration time.Duration) *BoolCmd {
	cmd := NewBoolCmd("PEXPIRE", key, formatMs(expiration))
	c.Process(cmd)
	return cmd
}
func (c *commandable) PExpireAt(key string, tm time.Time) *BoolCmd {
	cmd := NewBoolCmd(
		"PEXPIREAT",
		key,
		formatInt(tm.UnixNano()/int64(time.Millisecond)),
	)
	c.Process(cmd)
	return cmd
}
func (c *commandable) PTTL(key string) *DurationCmd {
	cmd := NewDurationCmd(time.Millisecond, "PTTL", key)
	c.Process(cmd)
	return cmd
}
func (c *commandable) RandomKey() *StringCmd {
	cmd := NewStringCmd("RANDOMKEY")
	c.Process(cmd)
	return cmd
}
func (c *commandable) Rename(key, newkey string) *StatusCmd {
	cmd := NewStatusCmd("RENAME", key, newkey)
	c.Process(cmd)
	return cmd
}
func (c *commandable) RenameNX(key, newkey string) *BoolCmd {
	cmd := NewBoolCmd("RENAMENX", key, newkey)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Restore(key string, ttl time.Duration, value string) *StatusCmd {
	cmd := NewStatusCmd(
		"RESTORE",
		key,
		formatMs(ttl),
		value,
	)
	c.Process(cmd)
	return cmd
}
func (c *commandable) RestoreReplace(key string, ttl time.Duration, value string) *StatusCmd {
	cmd := NewStatusCmd(
		"RESTORE",
		key,
		formatMs(ttl),
		value,
		"REPLACE",
	)
	c.Process(cmd)
	return cmd
}
type Sort struct {
	By            string
	Offset, Count float64
	Get           []string
	Order         string
	IsAlpha       bool
	Store         string
}
func (c *commandable) Sort(key string, sort Sort) *StringSliceCmd {
	args := []interface{}{"SORT", key}
	if sort.By != "" {
		args = append(args, "BY", sort.By)
	}
	if sort.Offset != 0 || sort.Count != 0 {
		args = append(args, "LIMIT", formatFloat(sort.Offset), formatFloat(sort.Count))
	}
	for _, get := range sort.Get {
		args = append(args, "GET", get)
	}
	if sort.Order != "" {
		args = append(args, sort.Order)
	}
	if sort.IsAlpha {
		args = append(args, "ALPHA")
	}
	if sort.Store != "" {
		args = append(args, "STORE", sort.Store)
	}
	cmd := NewStringSliceCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) TTL(key string) *DurationCmd {
	cmd := NewDurationCmd(time.Second, "TTL", key)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Type(key string) *StatusCmd {
	cmd := NewStatusCmd("TYPE", key)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Scan(cursor int64, match string, count int64) *ScanCmd {
	args := []interface{}{"SCAN", formatInt(cursor)}
	if match != "" {
		args = append(args, "MATCH", match)
	}
	if count > 0 {
		args = append(args, "COUNT", formatInt(count))
	}
	cmd := NewScanCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) SScan(key string, cursor int64, match string, count int64) *ScanCmd {
	args := []interface{}{"SSCAN", key, formatInt(cursor)}
	if match != "" {
		args = append(args, "MATCH", match)
	}
	if count > 0 {
		args = append(args, "COUNT", formatInt(count))
	}
	cmd := NewScanCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) HScan(key string, cursor int64, match string, count int64) *ScanCmd {
	args := []interface{}{"HSCAN", key, formatInt(cursor)}
	if match != "" {
		args = append(args, "MATCH", match)
	}
	if count > 0 {
		args = append(args, "COUNT", formatInt(count))
	}
	cmd := NewScanCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) ZScan(key string, cursor int64, match string, count int64) *ScanCmd {
	args := []interface{}{"ZSCAN", key, formatInt(cursor)}
	if match != "" {
		args = append(args, "MATCH", match)
	}
	if count > 0 {
		args = append(args, "COUNT", formatInt(count))
	}
	cmd := NewScanCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Append(key, value string) *IntCmd {
	cmd := NewIntCmd("APPEND", key, value)
	c.Process(cmd)
	return cmd
}
type BitCount struct {
	Start, End int64
}
func (c *commandable) BitCount(key string, bitCount *BitCount) *IntCmd {
	args := []interface{}{"BITCOUNT", key}
	if bitCount != nil {
		args = append(
			args,
			formatInt(bitCount.Start),
			formatInt(bitCount.End),
		)
	}
	cmd := NewIntCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) bitOp(op, destKey string, keys ...string) *IntCmd {
	args := make([]interface{}, 3+len(keys))
	args[0] = "BITOP"
	args[1] = op
	args[2] = destKey
	for i, key := range keys {
		args[3+i] = key
	}
	cmd := NewIntCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) BitOpAnd(destKey string, keys ...string) *IntCmd {
	return c.bitOp("AND", destKey, keys...)
}
func (c *commandable) BitOpOr(destKey string, keys ...string) *IntCmd {
	return c.bitOp("OR", destKey, keys...)
}
func (c *commandable) BitOpXor(destKey string, keys ...string) *IntCmd {
	return c.bitOp("XOR", destKey, keys...)
}
func (c *commandable) BitOpNot(destKey string, key string) *IntCmd {
	return c.bitOp("NOT", destKey, key)
}
func (c *commandable) BitPos(key string, bit int64, pos ...int64) *IntCmd {
	args := make([]interface{}, 3+len(pos))
	args[0] = "BITPOS"
	args[1] = key
	args[2] = formatInt(bit)
	switch len(pos) {
	case 0:
	case 1:
		args[3] = formatInt(pos[0])
	case 2:
		args[3] = formatInt(pos[0])
		args[4] = formatInt(pos[1])
	default:
		panic("too many arguments")
	}
	cmd := NewIntCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Decr(key string) *IntCmd {
	cmd := NewIntCmd("DECR", key)
	c.Process(cmd)
	return cmd
}
func (c *commandable) DecrBy(key string, decrement int64) *IntCmd {
	cmd := NewIntCmd("DECRBY", key, formatInt(decrement))
	c.Process(cmd)
	return cmd
}
func (c *commandable) Get(key string) *StringCmd {
	cmd := NewStringCmd("GET", key)
	c.Process(cmd)
	return cmd
}
func (c *commandable) GetBit(key string, offset int64) *IntCmd {
	cmd := NewIntCmd("GETBIT", key, formatInt(offset))
	c.Process(cmd)
	return cmd
}
func (c *commandable) GetRange(key string, start, end int64) *StringCmd {
	cmd := NewStringCmd(
		"GETRANGE",
		key,
		formatInt(start),
		formatInt(end),
	)
	c.Process(cmd)
	return cmd
}
func (c *commandable) GetSet(key string, value interface{}) *StringCmd {
	cmd := NewStringCmd("GETSET", key, value)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Incr(key string) *IntCmd {
	cmd := NewIntCmd("INCR", key)
	c.Process(cmd)
	return cmd
}
func (c *commandable) IncrBy(key string, value int64) *IntCmd {
	cmd := NewIntCmd("INCRBY", key, formatInt(value))
	c.Process(cmd)
	return cmd
}
func (c *commandable) IncrByFloat(key string, value float64) *FloatCmd {
	cmd := NewFloatCmd("INCRBYFLOAT", key, formatFloat(value))
	c.Process(cmd)
	return cmd
}
func (c *commandable) MGet(keys ...string) *SliceCmd {
	args := make([]interface{}, 1+len(keys))
	args[0] = "MGET"
	for i, key := range keys {
		args[1+i] = key
	}
	cmd := NewSliceCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) MSet(pairs ...string) *StatusCmd {
	args := make([]interface{}, 1+len(pairs))
	args[0] = "MSET"
	for i, pair := range pairs {
		args[1+i] = pair
	}
	cmd := NewStatusCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) MSetNX(pairs ...string) *BoolCmd {
	args := make([]interface{}, 1+len(pairs))
	args[0] = "MSETNX"
	for i, pair := range pairs {
		args[1+i] = pair
	}
	cmd := NewBoolCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) Set(key string, value interface{}, expiration time.Duration) *StatusCmd {
	args := make([]interface{}, 3, 5)
	args[0] = "SET"
	args[1] = key
	args[2] = value
	if expiration > 0 {
		if usePrecise(expiration) {
			args = append(args, "PX", formatMs(expiration))
		} else {
			args = append(args, "EX", formatSec(expiration))
		}
	}
	cmd := NewStatusCmd(args...)
	c.Process(cmd)
	return cmd
}
func (c *commandable) SetBit(key string, offset int64, value int) *IntCmd {
	cmd := NewIntCmd(
		"SETBIT",
		key,
		formatInt(offset),
		formatInt(int64(value)),
	)
	c.Process(cmd)
	return cmd
}