|
@@ -4,6 +4,7 @@ import (
|
|
|
. "app.yhyue.com/moapp/jybase/api"
|
|
|
"app.yhyue.com/moapp/jybase/common"
|
|
|
"app.yhyue.com/moapp/jybase/go-xweb/xweb"
|
|
|
+ "app.yhyue.com/moapp/jybase/redis"
|
|
|
"fmt"
|
|
|
"jy-docs/config"
|
|
|
"jy-docs/public"
|
|
@@ -176,11 +177,19 @@ func (stdDoc *StdDoc) TopList() {
|
|
|
} else {
|
|
|
return nil, fmt.Errorf("未知请求")
|
|
|
}
|
|
|
- //存入redis缓存
|
|
|
+ topKey := fmt.Sprintf("jydoc_indexCache_%s_%d", reqSort, num)
|
|
|
+ listCache := redis.Get("other", topKey)
|
|
|
+ if listCache != nil {
|
|
|
+ return listCache, nil
|
|
|
+ }
|
|
|
+ log.Println("flush", topKey)
|
|
|
list, _, err := rpc.GetDocQuery(userId, "", "", 1, num, reqSort)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+ if len(list) > 0 { //存入redis缓存
|
|
|
+ redis.Put("other", topKey, list, 60*5)
|
|
|
+ }
|
|
|
return list, nil
|
|
|
}()
|
|
|
if errMsg != nil {
|