@@ -30,8 +30,11 @@ func NodeInfo(ctx *context.APIContext) {
30
30
31
31
nodeInfoUsage := structs.NodeInfoUsage {}
32
32
if setting .Federation .ShareUserStatistics {
33
- info , ok := ctx .Cache .Get (cacheKeyNodeInfoUsage ).(structs.NodeInfoUsage )
34
- if ! ok {
33
+ cached := false
34
+ if setting .CacheService .Enabled {
35
+ nodeInfoUsage , cached = ctx .Cache .Get (cacheKeyNodeInfoUsage ).(structs.NodeInfoUsage )
36
+ }
37
+ if ! cached {
35
38
usersTotal := int (user_model .CountUsers (nil ))
36
39
now := time .Now ()
37
40
timeOneMonthAgo := now .AddDate (0 , - 1 , 0 ).Unix ()
@@ -42,7 +45,7 @@ func NodeInfo(ctx *context.APIContext) {
42
45
allIssues , _ := models .CountIssues (& models.IssuesOptions {})
43
46
allComments , _ := models .CountComments (& models.FindCommentsOptions {})
44
47
45
- info = structs.NodeInfoUsage {
48
+ nodeInfoUsage = structs.NodeInfoUsage {
46
49
Users : structs.NodeInfoUsageUsers {
47
50
Total : usersTotal ,
48
51
ActiveMonth : usersActiveMonth ,
@@ -51,12 +54,13 @@ func NodeInfo(ctx *context.APIContext) {
51
54
LocalPosts : int (allIssues ),
52
55
LocalComments : int (allComments ),
53
56
}
54
- if err := ctx .Cache .Put (cacheKeyNodeInfoUsage , nodeInfoUsage , 180 ); err != nil {
55
- ctx .InternalServerError (err )
56
- return
57
+ if setting .CacheService .Enabled {
58
+ if err := ctx .Cache .Put (cacheKeyNodeInfoUsage , nodeInfoUsage , 180 ); err != nil {
59
+ ctx .InternalServerError (err )
60
+ return
61
+ }
57
62
}
58
63
}
59
- nodeInfoUsage = info
60
64
}
61
65
62
66
nodeInfo := & structs.NodeInfo {
0 commit comments