summaryrefslogtreecommitdiffstats
path: root/store/sql_file_info_store.go
diff options
context:
space:
mode:
authorChris <ccbrown112@gmail.com>2017-09-14 12:01:44 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2017-09-14 13:01:44 -0400
commitb6fb98a43176215f16fc52b64abebde51355e5c1 (patch)
tree095a2006bdfdd30d1a9c4fc4e604924fc0f50225 /store/sql_file_info_store.go
parentaf81f7e48bd2afaaa8c71f78bf86bdc00b104e4d (diff)
downloadchat-b6fb98a43176215f16fc52b64abebde51355e5c1.tar.gz
chat-b6fb98a43176215f16fc52b64abebde51355e5c1.tar.bz2
chat-b6fb98a43176215f16fc52b64abebde51355e5c1.zip
remove more global references (#7442)
Diffstat (limited to 'store/sql_file_info_store.go')
-rw-r--r--store/sql_file_info_store.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/store/sql_file_info_store.go b/store/sql_file_info_store.go
index fc4a9513f..eab83992f 100644
--- a/store/sql_file_info_store.go
+++ b/store/sql_file_info_store.go
@@ -13,6 +13,7 @@ import (
type SqlFileInfoStore struct {
SqlStore
+ metrics einterfaces.MetricsInterface
}
const (
@@ -26,8 +27,11 @@ func ClearFileCaches() {
fileInfoCache.Purge()
}
-func NewSqlFileInfoStore(sqlStore SqlStore) FileInfoStore {
- s := &SqlFileInfoStore{sqlStore}
+func NewSqlFileInfoStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface) FileInfoStore {
+ s := &SqlFileInfoStore{
+ SqlStore: sqlStore,
+ metrics: metrics,
+ }
for _, db := range sqlStore.GetAllConns() {
table := db.AddTableWithName(model.FileInfo{}, "FileInfo").SetKeys(false, "Id")
@@ -149,12 +153,10 @@ func (fs SqlFileInfoStore) GetForPost(postId string, readFromMaster bool, allowF
go func() {
result := StoreResult{}
- metrics := einterfaces.GetMetricsInterface()
-
if allowFromCache {
if cacheItem, ok := fileInfoCache.Get(postId); ok {
- if metrics != nil {
- metrics.IncrementMemCacheHitCounter("File Info Cache")
+ if fs.metrics != nil {
+ fs.metrics.IncrementMemCacheHitCounter("File Info Cache")
}
result.Data = cacheItem.([]*model.FileInfo)
@@ -162,13 +164,13 @@ func (fs SqlFileInfoStore) GetForPost(postId string, readFromMaster bool, allowF
close(storeChannel)
return
} else {
- if metrics != nil {
- metrics.IncrementMemCacheMissCounter("File Info Cache")
+ if fs.metrics != nil {
+ fs.metrics.IncrementMemCacheMissCounter("File Info Cache")
}
}
} else {
- if metrics != nil {
- metrics.IncrementMemCacheMissCounter("File Info Cache")
+ if fs.metrics != nil {
+ fs.metrics.IncrementMemCacheMissCounter("File Info Cache")
}
}