summaryrefslogtreecommitdiffstats
path: root/store/sql_channel_store.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2017-01-03 11:45:45 -0500
committerenahum <nahumhbl@gmail.com>2017-01-03 13:45:45 -0300
commitf48c646208cb5227b8f6c6a5139bf9af66da802d (patch)
tree99c53f9bf77f43705933c78e062061177b948aa5 /store/sql_channel_store.go
parentf94e220c88e2c233536f48ce42a2dfba8c3403b8 (diff)
downloadchat-f48c646208cb5227b8f6c6a5139bf9af66da802d.tar.gz
chat-f48c646208cb5227b8f6c6a5139bf9af66da802d.tar.bz2
chat-f48c646208cb5227b8f6c6a5139bf9af66da802d.zip
Fixing should send event removing extra go channel creation (#4942)
Diffstat (limited to 'store/sql_channel_store.go')
-rw-r--r--store/sql_channel_store.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 7cdebba8a..2ab9d87c1 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -839,6 +839,27 @@ func (us SqlChannelStore) InvalidateMemberCount(channelId string) {
channelMemberCountsCache.Remove(channelId)
}
+func (s SqlChannelStore) GetMemberCountFromCache(channelId string) int64 {
+ metrics := einterfaces.GetMetricsInterface()
+
+ if cacheItem, ok := channelMemberCountsCache.Get(channelId); ok {
+ if metrics != nil {
+ metrics.IncrementMemCacheHitCounter("Channel Member Counts")
+ }
+ return cacheItem.(int64)
+ } else {
+ if metrics != nil {
+ metrics.IncrementMemCacheMissCounter("Channel Member Counts")
+ }
+ }
+
+ if result := <-s.GetMemberCount(channelId, true); result.Err != nil {
+ return 0
+ } else {
+ return result.Data.(int64)
+ }
+}
+
func (s SqlChannelStore) GetMemberCount(channelId string, allowFromCache bool) StoreChannel {
storeChannel := make(StoreChannel, 1)
metrics := einterfaces.GetMetricsInterface()