From b6fb98a43176215f16fc52b64abebde51355e5c1 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 14 Sep 2017 12:01:44 -0500 Subject: remove more global references (#7442) --- store/sql_file_info_store.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'store/sql_file_info_store.go') 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") } } -- cgit v1.2.3-1-g7c22