v2
This commit is contained in:
1
business/jxutils/cache/cache.go
vendored
1
business/jxutils/cache/cache.go
vendored
@@ -12,6 +12,7 @@ type ICacher interface {
|
||||
GetAs(key string, ptr interface{}) error
|
||||
Keys(prefix string) ([]string, error)
|
||||
|
||||
GetString(key string) string
|
||||
FlushDB() error
|
||||
Incr(key string) error
|
||||
LRange(key string) (retVal []string)
|
||||
|
||||
13
business/jxutils/cache/redis/redis.go
vendored
13
business/jxutils/cache/redis/redis.go
vendored
@@ -1,6 +1,7 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -60,6 +61,18 @@ func (c *Cacher) Get(key string) interface{} {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cacher) GetString(key string) string {
|
||||
result, err := c.client.Get(key).Result()
|
||||
if err == nil {
|
||||
//return result
|
||||
var retVal interface{}
|
||||
if err = json.Unmarshal([]byte(result), &retVal); err == nil {
|
||||
return retVal.(string)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (c *Cacher) GetAs(key string, ptr interface{}) error {
|
||||
result, err := c.client.Get(key).Result()
|
||||
if err == nil {
|
||||
|
||||
Reference in New Issue
Block a user