im2
This commit is contained in:
18
business/jxutils/cache/cache.go
vendored
18
business/jxutils/cache/cache.go
vendored
@@ -12,13 +12,13 @@ type ICacher interface {
|
||||
GetAs(key string, ptr interface{}) error
|
||||
Keys(prefix string) ([]string, error)
|
||||
|
||||
//FlushDB() error
|
||||
//Incr(key string) error
|
||||
//LRange(key string) (retVal []string)
|
||||
//Exists(keys ...string) (int64, error)
|
||||
//RPush(key string, value interface{}) error
|
||||
//Expire(key string, expiration time.Duration) error
|
||||
//LRem(key string, count int, value interface{}) error
|
||||
//LSet(key string, index int, value interface{}) error
|
||||
//ExpireResult(key string, expiration time.Duration) (bool, error)
|
||||
FlushDB() error
|
||||
Incr(key string) error
|
||||
LRange(key string) (retVal []string)
|
||||
Exists(keys ...string) (int64, error)
|
||||
RPush(key string, value interface{}) error
|
||||
Expire(key string, expiration time.Duration) error
|
||||
LRem(key string, count int, value interface{}) error
|
||||
LSet(key string, index int, value interface{}) error
|
||||
ExpireResult(key string, expiration time.Duration) (bool, error)
|
||||
}
|
||||
|
||||
86
business/jxutils/cache/redis/redis.go
vendored
86
business/jxutils/cache/redis/redis.go
vendored
@@ -74,46 +74,46 @@ func (c *Cacher) Keys(prefix string) ([]string, error) {
|
||||
return c.client.Keys(prefix + "*").Result()
|
||||
}
|
||||
|
||||
//func (c *Cacher) RPush(key string, value interface{}) error {
|
||||
// return c.client.RPush(key, value).Err()
|
||||
//}
|
||||
//
|
||||
//func (c *Cacher) FlushDB() error {
|
||||
// return c.client.FlushDB().Err()
|
||||
//}
|
||||
//
|
||||
//func (c *Cacher) Expire(key string, expiration time.Duration) error {
|
||||
// return c.client.Expire(key, expiration).Err()
|
||||
//}
|
||||
//
|
||||
//func (c *Cacher) ExpireResult(key string, expiration time.Duration) (bool, error) {
|
||||
// ok, err := c.client.Expire(key, expiration).Result()
|
||||
// if err != nil {
|
||||
// return false, err
|
||||
// }
|
||||
// return ok, nil
|
||||
//}
|
||||
//
|
||||
//func (c *Cacher) Exists(keys ...string) (int64, error) {
|
||||
// ret := c.client.Exists(keys...)
|
||||
// return ret.Val(), ret.Err()
|
||||
//}
|
||||
//
|
||||
//func (c *Cacher) Incr(key string) error {
|
||||
// return c.client.Incr(key).Err()
|
||||
//}
|
||||
//
|
||||
//func (c *Cacher) LRange(key string) (retVal []string) {
|
||||
// if c.client.LLen(key).Val() > 0 {
|
||||
// retVal = c.client.LRange(key, 0, -1).Val()
|
||||
// }
|
||||
// return retVal
|
||||
//}
|
||||
//
|
||||
//func (c *Cacher) LSet(key string, index int, value interface{}) error {
|
||||
// return c.client.LSet(key, int64(index), value).Err()
|
||||
//}
|
||||
//
|
||||
//func (c *Cacher) LRem(key string, count int, value interface{}) error {
|
||||
// return c.client.LRem(key, int64(count), value).Err()
|
||||
//}
|
||||
func (c *Cacher) RPush(key string, value interface{}) error {
|
||||
return c.client.RPush(key, value).Err()
|
||||
}
|
||||
|
||||
func (c *Cacher) FlushDB() error {
|
||||
return c.client.FlushDB().Err()
|
||||
}
|
||||
|
||||
func (c *Cacher) Expire(key string, expiration time.Duration) error {
|
||||
return c.client.Expire(key, expiration).Err()
|
||||
}
|
||||
|
||||
func (c *Cacher) ExpireResult(key string, expiration time.Duration) (bool, error) {
|
||||
ok, err := c.client.Expire(key, expiration).Result()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return ok, nil
|
||||
}
|
||||
|
||||
func (c *Cacher) Exists(keys ...string) (int64, error) {
|
||||
ret := c.client.Exists(keys...)
|
||||
return ret.Val(), ret.Err()
|
||||
}
|
||||
|
||||
func (c *Cacher) Incr(key string) error {
|
||||
return c.client.Incr(key).Err()
|
||||
}
|
||||
|
||||
func (c *Cacher) LRange(key string) (retVal []string) {
|
||||
if c.client.LLen(key).Val() > 0 {
|
||||
retVal = c.client.LRange(key, 0, -1).Val()
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
func (c *Cacher) LSet(key string, index int, value interface{}) error {
|
||||
return c.client.LSet(key, int64(index), value).Err()
|
||||
}
|
||||
|
||||
func (c *Cacher) LRem(key string, count int, value interface{}) error {
|
||||
return c.client.LRem(key, int64(count), value).Err()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user