|
@@ -214,7 +214,12 @@ func GetInt(code, key string) int {
|
|
|
}
|
|
|
|
|
|
//取得字符串,支持变参,2个 (key,code),返回后自己断言
|
|
|
-func Get(code, key string) interface{} {
|
|
|
+func Get(code, key string) (result interface{}) {
|
|
|
+ GetInterface(code, key, &result)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func GetInterface(code, key string, result interface{}) {
|
|
|
defer func() {
|
|
|
if r := recover(); r != nil {
|
|
|
log.Println("[E]", r)
|
|
@@ -231,17 +236,15 @@ func Get(code, key string) interface{} {
|
|
|
conn := RedisPool[code].Get()
|
|
|
defer conn.Close()
|
|
|
ret, err := conn.Do("GET", key)
|
|
|
- var result interface{}
|
|
|
if nil != err {
|
|
|
log.Println("redisutil-GetError", err)
|
|
|
} else {
|
|
|
var ok bool
|
|
|
var res []byte
|
|
|
if res, ok = ret.([]byte); ok {
|
|
|
- err = json.Unmarshal(res, &result)
|
|
|
+ err = json.Unmarshal(res, result)
|
|
|
}
|
|
|
}
|
|
|
- return result
|
|
|
}
|
|
|
|
|
|
//直接返回字节流
|