summaryrefslogtreecommitdiffstats
path: root/store
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-02-27 17:43:23 -0500
committerChristopher Speller <crspeller@gmail.com>2017-02-27 17:43:23 -0500
commit83c113595ace467ad34f05e35fb2282fa8631a17 (patch)
treecb69e0bf9d2a04e0d622e5151181c65527bc90bc /store
parent55752fb359f805196e9acc1497cee658d30fa6ed (diff)
downloadchat-83c113595ace467ad34f05e35fb2282fa8631a17.tar.gz
chat-83c113595ace467ad34f05e35fb2282fa8631a17.tar.bz2
chat-83c113595ace467ad34f05e35fb2282fa8631a17.zip
Revert "Adding caching to get channel member (#5518)"
This reverts commit ba028ed74b69bd1dd902344663fbf8ba4f1dfb87.
Diffstat (limited to 'store')
-rw-r--r--store/sql_channel_store.go34
-rw-r--r--store/sql_channel_store_test.go10
-rw-r--r--store/store.go3
3 files changed, 7 insertions, 40 deletions
diff --git a/store/sql_channel_store.go b/store/sql_channel_store.go
index 068692074..ea32317a3 100644
--- a/store/sql_channel_store.go
+++ b/store/sql_channel_store.go
@@ -28,9 +28,6 @@ const (
ALL_CHANNEL_MEMBERS_NOTIFY_PROPS_FOR_CHANNEL_CACHE_SIZE = model.SESSION_CACHE_SIZE
ALL_CHANNEL_MEMBERS_NOTIFY_PROPS_FOR_CHANNEL_CACHE_SEC = 1800 // 30 mins
- CHANNEL_MEMBER_CACHE_SIZE = model.SESSION_CACHE_SIZE
- CHANNEL_MEMBER_CACHE_SEC = 900 // 15 mins
-
CHANNEL_MEMBERS_COUNTS_CACHE_SIZE = model.CHANNEL_CACHE_SIZE
CHANNEL_MEMBERS_COUNTS_CACHE_SEC = 1800 // 30 mins
@@ -46,7 +43,6 @@ var allChannelMembersForUserCache = utils.NewLru(ALL_CHANNEL_MEMBERS_FOR_USER_CA
var allChannelMembersNotifyPropsForChannelCache = utils.NewLru(ALL_CHANNEL_MEMBERS_NOTIFY_PROPS_FOR_CHANNEL_CACHE_SIZE)
var channelCache = utils.NewLru(model.CHANNEL_CACHE_SIZE)
var channelByNameCache = utils.NewLru(model.CHANNEL_CACHE_SIZE)
-var channelMemberCache = utils.NewLru(CHANNEL_MEMBER_CACHE_SIZE)
func ClearChannelCaches() {
channelMemberCountsCache.Purge()
@@ -54,7 +50,6 @@ func ClearChannelCaches() {
allChannelMembersNotifyPropsForChannelCache.Purge()
channelCache.Purge()
channelByNameCache.Purge()
- channelMemberCache.Purge()
}
func NewSqlChannelStore(sqlStore *SqlStore) ChannelStore {
@@ -781,36 +776,11 @@ func (s SqlChannelStore) GetMembers(channelId string, offset, limit int) StoreCh
return storeChannel
}
-func (s SqlChannelStore) InvalidateMember(channelId string, userId string) {
- channelMemberCache.Remove(channelId + userId)
-}
-
-func (s SqlChannelStore) GetMember(channelId string, userId string, allowFromCache bool) StoreChannel {
+func (s SqlChannelStore) GetMember(channelId string, userId string) StoreChannel {
storeChannel := make(StoreChannel, 1)
go func() {
result := StoreResult{}
- metrics := einterfaces.GetMetricsInterface()
-
- if allowFromCache {
- if cacheItem, ok := channelMemberCache.Get(channelId + userId); ok {
- if metrics != nil {
- metrics.IncrementMemCacheHitCounter("Channel Member")
- }
- result.Data = cacheItem.(*model.ChannelMember)
- storeChannel <- result
- close(storeChannel)
- return
- } else {
- if metrics != nil {
- metrics.IncrementMemCacheMissCounter("Channel Member")
- }
- }
- } else {
- if metrics != nil {
- metrics.IncrementMemCacheMissCounter("Channel Member")
- }
- }
var member model.ChannelMember
@@ -822,8 +792,6 @@ func (s SqlChannelStore) GetMember(channelId string, userId string, allowFromCac
}
} else {
result.Data = &member
-
- channelMemberCache.AddWithExpiresInSecs(channelId+userId, &member, CHANNEL_MEMBER_CACHE_SEC)
}
storeChannel <- result
diff --git a/store/sql_channel_store_test.go b/store/sql_channel_store_test.go
index a43b97706..df9c76905 100644
--- a/store/sql_channel_store_test.go
+++ b/store/sql_channel_store_test.go
@@ -497,7 +497,7 @@ func TestChannelMemberStore(t *testing.T) {
t.Fatal("Member update time incorrect on delete")
}
- member := (<-store.Channel().GetMember(o1.ChannelId, o1.UserId, false)).Data.(*model.ChannelMember)
+ member := (<-store.Channel().GetMember(o1.ChannelId, o1.UserId)).Data.(*model.ChannelMember)
if member.ChannelId != o1.ChannelId {
t.Fatal("should have go member")
}
@@ -968,15 +968,15 @@ func TestGetMember(t *testing.T) {
}
Must(store.Channel().SaveMember(m2))
- if result := <-store.Channel().GetMember(model.NewId(), userId, false); result.Err == nil {
+ if result := <-store.Channel().GetMember(model.NewId(), userId); result.Err == nil {
t.Fatal("should've failed to get member for non-existant channel")
}
- if result := <-store.Channel().GetMember(c1.Id, model.NewId(), false); result.Err == nil {
+ if result := <-store.Channel().GetMember(c1.Id, model.NewId()); result.Err == nil {
t.Fatal("should've failed to get member for non-existant user")
}
- if result := <-store.Channel().GetMember(c1.Id, userId, false); result.Err != nil {
+ if result := <-store.Channel().GetMember(c1.Id, userId); result.Err != nil {
t.Fatal("shouldn't have errored when getting member", result.Err)
} else if member := result.Data.(*model.ChannelMember); member.ChannelId != c1.Id {
t.Fatal("should've gotten member of channel 1")
@@ -984,7 +984,7 @@ func TestGetMember(t *testing.T) {
t.Fatal("should've gotten member for user")
}
- if result := <-store.Channel().GetMember(c2.Id, userId, false); result.Err != nil {
+ if result := <-store.Channel().GetMember(c2.Id, userId); result.Err != nil {
t.Fatal("shouldn't have errored when getting member", result.Err)
} else if member := result.Data.(*model.ChannelMember); member.ChannelId != c2.Id {
t.Fatal("should've gotten member of channel 2")
diff --git a/store/store.go b/store/store.go
index 06564a8c2..4226f03a5 100644
--- a/store/store.go
+++ b/store/store.go
@@ -106,8 +106,7 @@ type ChannelStore interface {
SaveMember(member *model.ChannelMember) StoreChannel
UpdateMember(member *model.ChannelMember) StoreChannel
GetMembers(channelId string, offset, limit int) StoreChannel
- GetMember(channelId string, userId string, allowFromCache bool) StoreChannel
- InvalidateMember(channelId string, userId string)
+ GetMember(channelId string, userId string) StoreChannel
GetAllChannelMembersForUser(userId string, allowFromCache bool) StoreChannel
InvalidateAllChannelMembersForUser(userId string)
IsUserInChannelUseCache(userId string, channelId string) bool