1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package cache
- import (
- "time"
- )
- func (p *RedisCache) Expire(key string, seconds int64) (bool, error) {
- if p.isCluster {
- return p.cluster.Expire(key, time.Duration(seconds)*time.Second).Result()
- }
- return p.client.Expire(key, time.Duration(seconds)*time.Second).Result()
- }
- func (p *RedisCache) Exists(keys ...string) (int64, error) {
- if p.isCluster {
- n := int64(0)
- for _, key := range keys {
- v, err := p.cluster.Exists(key).Result()
- if err != nil {
- return n, err
- }
- n += v
- }
- return n, nil
- }
- return p.client.Exists(keys...).Result()
- }
- func (p *RedisCache) Del(keys ...string) (int64, error) {
- if p.isCluster {
- n := int64(0)
- for _, key := range keys {
- v, err := p.cluster.Del(key).Result()
- if err != nil {
- return n, err
- }
- n += v
- }
- return n, nil
- }
- return p.client.Del(keys...).Result()
- }
- func (p *RedisCache) IncrBy(key string, value int64) (int64, error) {
- if p.isCluster {
- return p.cluster.IncrBy(key, value).Result()
- }
- return p.client.IncrBy(key, value).Result()
- }
- func (p *RedisCache) Rename(key string, newkey string) (string, error) {
- if p.isCluster {
- return p.cluster.Rename(key, newkey).Result()
- }
- return p.client.Rename(key, newkey).Result()
- }
|