File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,10 @@ func (feedCache) GetTop(ctx context.Context) []*model.Feed {
2222 return nil
2323 }
2424
25+ if s == "notop" {
26+ return []* model.Feed {}
27+ }
28+
2529 feeds := make ([]* model.Feed , 0 )
2630 err := json .Unmarshal ([]byte (s ), & feeds )
2731 if err != nil {
@@ -35,8 +39,13 @@ func (feedCache) SetTop(ctx context.Context, feeds []*model.Feed) {
3539 redisClient := nosql .NewRedisClient ()
3640 defer redisClient .Close ()
3741
38- b , _ := json .Marshal (feeds )
39- redisClient .SET ("feed:top" , string (b ), 300 )
42+ val := "notop"
43+ if len (feeds ) > 0 {
44+ b , _ := json .Marshal (feeds )
45+ val = string (b )
46+ }
47+
48+ redisClient .SET ("feed:top" , val , 300 )
4049}
4150
4251func (feedCache ) GetList (ctx context.Context , p int ) []* model.Feed {
Original file line number Diff line number Diff line change @@ -80,7 +80,7 @@ func (self FeedLogic) FindTop(ctx context.Context) []*model.Feed {
8080 objLog := GetLogger (ctx )
8181
8282 feeds := cache .Feed .GetTop (ctx )
83- if len ( feeds ) > 0 {
83+ if feeds != nil {
8484 return feeds
8585 }
8686
@@ -92,9 +92,7 @@ func (self FeedLogic) FindTop(ctx context.Context) []*model.Feed {
9292 }
9393
9494 feeds = self .fillOtherInfo (ctx , feeds , false )
95- if len (feeds ) > 0 {
96- cache .Feed .SetTop (ctx , feeds )
97- }
95+ cache .Feed .SetTop (ctx , feeds )
9896 return feeds
9997}
10098
You can’t perform that action at this time.
0 commit comments