summaryrefslogtreecommitdiffstats
path: root/store/sql_emoji_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_emoji_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_emoji_store.go')
-rw-r--r--store/sql_emoji_store.go21
1 files changed, 12 insertions, 9 deletions
diff --git a/store/sql_emoji_store.go b/store/sql_emoji_store.go
index 5fd49ab3b..efab82d1f 100644
--- a/store/sql_emoji_store.go
+++ b/store/sql_emoji_store.go
@@ -20,10 +20,14 @@ var emojiCache *utils.Cache = utils.NewLru(EMOJI_CACHE_SIZE)
type SqlEmojiStore struct {
SqlStore
+ metrics einterfaces.MetricsInterface
}
-func NewSqlEmojiStore(sqlStore SqlStore) EmojiStore {
- s := &SqlEmojiStore{sqlStore}
+func NewSqlEmojiStore(sqlStore SqlStore, metrics einterfaces.MetricsInterface) EmojiStore {
+ s := &SqlEmojiStore{
+ SqlStore: sqlStore,
+ metrics: metrics,
+ }
for _, db := range sqlStore.GetAllConns() {
table := db.AddTableWithName(model.Emoji{}, "Emoji").SetKeys(false, "Id")
@@ -74,25 +78,24 @@ func (es SqlEmojiStore) Get(id string, allowFromCache bool) StoreChannel {
go func() {
result := StoreResult{}
- metrics := einterfaces.GetMetricsInterface()
if allowFromCache {
if cacheItem, ok := emojiCache.Get(id); ok {
- if metrics != nil {
- metrics.IncrementMemCacheHitCounter("Emoji")
+ if es.metrics != nil {
+ es.metrics.IncrementMemCacheHitCounter("Emoji")
}
result.Data = cacheItem.(*model.Emoji)
storeChannel <- result
close(storeChannel)
return
} else {
- if metrics != nil {
- metrics.IncrementMemCacheMissCounter("Emoji")
+ if es.metrics != nil {
+ es.metrics.IncrementMemCacheMissCounter("Emoji")
}
}
} else {
- if metrics != nil {
- metrics.IncrementMemCacheMissCounter("Emoji")
+ if es.metrics != nil {
+ es.metrics.IncrementMemCacheMissCounter("Emoji")
}
}