optimize index tweets from cache logic

pull/391/head
Michael Li 10 months ago
parent 8f32e827d6
commit ba40775da9
No known key found for this signature in database

@ -8,7 +8,6 @@ import (
"fmt"
"github.com/alimy/mir/v4"
"github.com/alimy/tryst/lets"
"github.com/gin-gonic/gin"
api "github.com/rocboss/paopao-ce/auto/api/v1"
"github.com/rocboss/paopao-ce/internal/conf"
@ -122,7 +121,10 @@ func (s *looseSrv) getIndexTweets(req *web.TimelineReq, limit int, offset int) (
func (s *looseSrv) indexTweetsFromCache(req *web.TimelineReq, limit int, offset int) (res *web.TimelineResp, key string, ok bool) {
switch req.Style {
case web.StyleTweetsFollowing:
username := lets.If(req.User != nil, req.User.Username, "_")
username := "_"
if req.User != nil {
username = req.User.Username
}
key = fmt.Sprintf("%s%s:%d:%d", s.prefixIdxTweetsFollowing, username, offset, limit)
case web.StyleTweetsNewest:
key = fmt.Sprintf("%s%d:%d", s.prefixIdxTweetsNewest, offset, limit)

Loading…
Cancel
Save