File tree 2 files changed +13
-6
lines changed
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 {
22
22
return nil
23
23
}
24
24
25
+ if s == "notop" {
26
+ return []* model.Feed {}
27
+ }
28
+
25
29
feeds := make ([]* model.Feed , 0 )
26
30
err := json .Unmarshal ([]byte (s ), & feeds )
27
31
if err != nil {
@@ -35,8 +39,13 @@ func (feedCache) SetTop(ctx context.Context, feeds []*model.Feed) {
35
39
redisClient := nosql .NewRedisClient ()
36
40
defer redisClient .Close ()
37
41
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 )
40
49
}
41
50
42
51
func (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 {
80
80
objLog := GetLogger (ctx )
81
81
82
82
feeds := cache .Feed .GetTop (ctx )
83
- if len ( feeds ) > 0 {
83
+ if feeds != nil {
84
84
return feeds
85
85
}
86
86
@@ -92,9 +92,7 @@ func (self FeedLogic) FindTop(ctx context.Context) []*model.Feed {
92
92
}
93
93
94
94
feeds = self .fillOtherInfo (ctx , feeds , false )
95
- if len (feeds ) > 0 {
96
- cache .Feed .SetTop (ctx , feeds )
97
- }
95
+ cache .Feed .SetTop (ctx , feeds )
98
96
return feeds
99
97
}
100
98
You can’t perform that action at this time.
0 commit comments