Documentation
¶
Index ¶
- type Redis
- func (r *Redis) DecrBy(key string, value int64) (int64, error)
- func (r *Redis) Delete(key string) error
- func (r *Redis) Do(cmd, key, seconds string) error
- func (r *Redis) Expire(key string, seconds time.Duration) (bool, error)
- func (r *Redis) Fetch(key string, fc func() interface{}) (string, error)
- func (r *Redis) Get(key string) (string, error)
- func (r *Redis) GetByte(key string) ([]byte, error)
- func (r *Redis) HDel(key string, field string) error
- func (r *Redis) HExists(key string, field string) error
- func (r *Redis) HGet(key string, field string) (string, error)
- func (r *Redis) HGetall(key string) (map[string]string, error)
- func (r *Redis) HLen(key string) (int64, error)
- func (r *Redis) HMSet(key string, fields map[string]interface{}) error
- func (r *Redis) HSet(key string, field string, value interface{}) error
- func (r *Redis) IncrBy(key string, value int64) (int64, error)
- func (r *Redis) LIndex(key string, index int64) (string, error)
- func (r *Redis) LLen(key string) (int64, error)
- func (r *Redis) LPush(key string, value interface{}) error
- func (r *Redis) LRange(key string) ([]string, error)
- func (r *Redis) LRem(key string, value interface{}) error
- func (r *Redis) LSet(key string, index int64, value interface{}) (string, error)
- func (r *Redis) RPush(key string, value interface{}) error
- func (r *Redis) SAdd(key string, field string) error
- func (r *Redis) SRandMember(key string) (string, error)
- func (r *Redis) Set(key string, value interface{}) error
- func (r *Redis) Unmarshal(key string, object interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Redis ¶
Redis provides a cache backed by a Redis server.
func (*Redis) Do ¶
Do 设置过期时间 EXPIRE/PEXPIREAT
EXPIRE aa 60 接口定义:EXPIRE key "seconds" 接口描述:设置一个key在当前时间"seconds"(秒)之后过期。返回1代表设置成功,返回0代表key不存在或者无法设置过期时间。
PEXPIRE 接口定义:PEXPIRE key "milliseconds" 接口描述:设置一个key在当前时间"milliseconds"(毫秒)之后过期。返回1代表设置成功,返回0代表key不存在或者无法设置过期时间。
EXPIREAT aa 1586941008 接口定义:EXPIREAT key "timestamp" 接口描述:设置一个key在"timestamp"(时间戳(秒))之后过期。返回1代表设置成功,返回0代表key不存在或者无法设置过期时间。
PEXPIREAT aa 1586941008000 接口定义:PEXPIREAT key "milliseconds-timestamp" 接口描述:设置一个key在"milliseconds-timestamp"(时间戳(毫秒))之后过期。返回1代表设置成功,返回0代表key不存在或者无法设置过期时间
TTL 接口定义:TTL key 接口描述:获取key的过期时间。如果key存在过期时间,返回剩余生存时间(秒);如果key是永久的,返回-1;如果key不存在或者已过期,返回-2。
PTTL 接口定义:PTTL key 接口描述:获取key的过期时间。如果key存在过期时间,返回剩余生存时间(毫秒);如果key是永久的,返回-1;如果key不存在或者已过期,返回-2。
PERSIST 接口定义:PERSIST key 接口描述:移除key的过期时间,将其转换为永久状态。如果返回1,代表转换成功。如果返回0,代表key不存在或者之前就已经是永久状态。
SETEX 接口定义:SETEX key "seconds" "value" 接口描述:SETEX在逻辑上等价于SET和EXPIRE合并的操作,区别之处在于SETEX是一条命令,而命令的执行是原子性的,所以不会出现并发问题。
func (*Redis) Fetch ¶
Fetch returns the value for the key if it exists or sets and returns the value via the passed function.