diff --git a/model/cluster_message.go b/model/cluster_message.go index 65408a5754..ce093216a9 100644 --- a/model/cluster_message.go +++ b/model/cluster_message.go @@ -29,6 +29,7 @@ const ( CLUSTER_EVENT_INVALIDATE_CACHE_FOR_WEBHOOKS = "inv_webhooks" CLUSTER_EVENT_INVALIDATE_CACHE_FOR_EMOJIS_BY_ID = "inv_emojis_by_id" CLUSTER_EVENT_INVALIDATE_CACHE_FOR_EMOJIS_ID_BY_NAME = "inv_emojis_id_by_name" + CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_PINNEDPOSTS_COUNTS = "inv_channel_pinnedposts_counts" CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBER_COUNTS = "inv_channel_member_counts" CLUSTER_EVENT_INVALIDATE_CACHE_FOR_LAST_POSTS = "inv_last_posts" CLUSTER_EVENT_CLEAR_SESSION_CACHE_FOR_ALL_USERS = "inv_all_user_sessions" diff --git a/store/localcachelayer/channel_layer.go b/store/localcachelayer/channel_layer.go index b9af5c3dfe..3e979a80da 100644 --- a/store/localcachelayer/channel_layer.go +++ b/store/localcachelayer/channel_layer.go @@ -21,6 +21,14 @@ func (s *LocalCacheChannelStore) handleClusterInvalidateChannelMemberCounts(msg } } +func (s *LocalCacheChannelStore) handleClusterInvalidateChannelPinnedPostCount(msg *model.ClusterMessage) { + if msg.Data == CLEAR_CACHE_MESSAGE_DATA { + s.rootStore.channelPinnedPostCountsCache.Purge() + } else { + s.rootStore.channelPinnedPostCountsCache.Remove(msg.Data) + } +} + func (s *LocalCacheChannelStore) handleClusterInvalidateChannelGuestCounts(msg *model.ClusterMessage) { if msg.Data == CLEAR_CACHE_MESSAGE_DATA { s.rootStore.channelGuestCountCache.Purge() @@ -31,14 +39,23 @@ func (s *LocalCacheChannelStore) handleClusterInvalidateChannelGuestCounts(msg * func (s LocalCacheChannelStore) ClearCaches() { s.rootStore.doClearCacheCluster(s.rootStore.channelMemberCountsCache) + s.rootStore.doClearCacheCluster(s.rootStore.channelPinnedPostCountsCache) s.rootStore.doClearCacheCluster(s.rootStore.channelGuestCountCache) s.ChannelStore.ClearCaches() if s.rootStore.metrics != nil { + s.rootStore.metrics.IncrementMemCacheInvalidationCounter("Channel Pinned Post Counts - Purge") s.rootStore.metrics.IncrementMemCacheInvalidationCounter("Channel Member Counts - Purge") s.rootStore.metrics.IncrementMemCacheInvalidationCounter("Channel Guest Count - Purge") } } +func (s LocalCacheChannelStore) InvalidatePinnedPostCount(channelId string) { + s.rootStore.doInvalidateCacheCluster(s.rootStore.channelPinnedPostCountsCache, channelId) + if s.rootStore.metrics != nil { + s.rootStore.metrics.IncrementMemCacheInvalidationCounter("Channel Pinned Post Counts - Remove by ChannelId") + } +} + func (s LocalCacheChannelStore) InvalidateMemberCount(channelId string) { s.rootStore.doInvalidateCacheCluster(s.rootStore.channelMemberCountsCache, channelId) if s.rootStore.metrics != nil { @@ -95,3 +112,23 @@ func (s LocalCacheChannelStore) GetMemberCountFromCache(channelId string) int64 return count } + +func (s LocalCacheChannelStore) GetPinnedPostCount(channelId string, allowFromCache bool) (int64, *model.AppError) { + if allowFromCache { + if count := s.rootStore.doStandardReadCache(s.rootStore.channelPinnedPostCountsCache, channelId); count != nil { + return count.(int64), nil + } + } + + count, err := s.ChannelStore.GetPinnedPostCount(channelId, allowFromCache) + + if err != nil { + return 0, err + } + + if allowFromCache { + s.rootStore.doStandardAddToCache(s.rootStore.channelPinnedPostCountsCache, channelId, count) + } + + return count, nil +} diff --git a/store/localcachelayer/channel_layer_test.go b/store/localcachelayer/channel_layer_test.go index 1564546ec7..6968ea8087 100644 --- a/store/localcachelayer/channel_layer_test.go +++ b/store/localcachelayer/channel_layer_test.go @@ -88,6 +88,68 @@ func TestChannelStoreChannelMemberCountsCache(t *testing.T) { }) } +func TestChannelStoreChannelPinnedPostsCountsCache(t *testing.T) { + countResult := int64(10) + + t.Run("first call not cached, second cached and returning same data", func(t *testing.T) { + mockStore := getMockStore() + cachedStore := NewLocalCacheLayer(mockStore, nil, nil) + + count, err := cachedStore.Channel().GetPinnedPostCount("id", true) + require.Nil(t, err) + assert.Equal(t, count, countResult) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 1) + count, err = cachedStore.Channel().GetPinnedPostCount("id", true) + require.Nil(t, err) + assert.Equal(t, count, countResult) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 1) + }) + + t.Run("first call not cached, second force no cached", func(t *testing.T) { + mockStore := getMockStore() + cachedStore := NewLocalCacheLayer(mockStore, nil, nil) + + cachedStore.Channel().GetPinnedPostCount("id", true) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 1) + cachedStore.Channel().GetPinnedPostCount("id", false) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 2) + }) + + t.Run("first call force no cached, second not cached, third cached", func(t *testing.T) { + mockStore := getMockStore() + cachedStore := NewLocalCacheLayer(mockStore, nil, nil) + + cachedStore.Channel().GetPinnedPostCount("id", false) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 1) + cachedStore.Channel().GetPinnedPostCount("id", true) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 2) + cachedStore.Channel().GetPinnedPostCount("id", true) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 2) + }) + + t.Run("first call not cached, clear cache, second call not cached", func(t *testing.T) { + mockStore := getMockStore() + cachedStore := NewLocalCacheLayer(mockStore, nil, nil) + + cachedStore.Channel().GetPinnedPostCount("id", true) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 1) + cachedStore.Channel().ClearCaches() + cachedStore.Channel().GetPinnedPostCount("id", true) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 2) + }) + + t.Run("first call not cached, invalidate cache, second call not cached", func(t *testing.T) { + mockStore := getMockStore() + cachedStore := NewLocalCacheLayer(mockStore, nil, nil) + + cachedStore.Channel().GetPinnedPostCount("id", true) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 1) + cachedStore.Channel().InvalidatePinnedPostCount("id") + cachedStore.Channel().GetPinnedPostCount("id", true) + mockStore.Channel().(*mocks.ChannelStore).AssertNumberOfCalls(t, "GetPinnedPostCount", 2) + }) +} + func TestChannelStoreGuestCountCache(t *testing.T) { countResult := int64(12) diff --git a/store/localcachelayer/layer.go b/store/localcachelayer/layer.go index 7d80a3f415..73de0b5e25 100644 --- a/store/localcachelayer/layer.go +++ b/store/localcachelayer/layer.go @@ -29,6 +29,9 @@ const ( EMOJI_CACHE_SIZE = 5000 EMOJI_CACHE_SEC = 30 * 60 + CHANNEL_PINNEDPOSTS_COUNTS_CACHE_SIZE = model.CHANNEL_CACHE_SIZE + CHANNEL_PINNEDPOSTS_COUNTS_CACHE_SEC = 30 * 60 + CHANNEL_MEMBERS_COUNTS_CACHE_SIZE = model.CHANNEL_CACHE_SIZE CHANNEL_MEMBERS_COUNTS_CACHE_SEC = 30 * 60 @@ -43,26 +46,27 @@ const ( type LocalCacheStore struct { store.Store - metrics einterfaces.MetricsInterface - cluster einterfaces.ClusterInterface - reaction LocalCacheReactionStore - reactionCache *utils.Cache - role LocalCacheRoleStore - roleCache *utils.Cache - scheme LocalCacheSchemeStore - schemeCache *utils.Cache - emoji LocalCacheEmojiStore - emojiCacheById *utils.Cache - emojiIdCacheByName *utils.Cache - channel LocalCacheChannelStore - channelMemberCountsCache *utils.Cache - channelGuestCountCache *utils.Cache - webhook LocalCacheWebhookStore - webhookCache *utils.Cache - post LocalCachePostStore - postLastPostsCache *utils.Cache - user LocalCacheUserStore - userProfileByIdsCache *utils.Cache + metrics einterfaces.MetricsInterface + cluster einterfaces.ClusterInterface + reaction LocalCacheReactionStore + reactionCache *utils.Cache + role LocalCacheRoleStore + roleCache *utils.Cache + scheme LocalCacheSchemeStore + schemeCache *utils.Cache + emoji LocalCacheEmojiStore + emojiCacheById *utils.Cache + emojiIdCacheByName *utils.Cache + channel LocalCacheChannelStore + channelMemberCountsCache *utils.Cache + channelGuestCountCache *utils.Cache + channelPinnedPostCountsCache *utils.Cache + webhook LocalCacheWebhookStore + webhookCache *utils.Cache + post LocalCachePostStore + postLastPostsCache *utils.Cache + user LocalCacheUserStore + userProfileByIdsCache *utils.Cache } func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterface, cluster einterfaces.ClusterInterface) LocalCacheStore { @@ -82,6 +86,7 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf localCacheStore.emojiCacheById = utils.NewLruWithParams(EMOJI_CACHE_SIZE, "EmojiById", EMOJI_CACHE_SEC, model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_EMOJIS_BY_ID) localCacheStore.emojiIdCacheByName = utils.NewLruWithParams(EMOJI_CACHE_SIZE, "EmojiByName", EMOJI_CACHE_SEC, model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_EMOJIS_ID_BY_NAME) localCacheStore.emoji = LocalCacheEmojiStore{EmojiStore: baseStore.Emoji(), rootStore: &localCacheStore} + localCacheStore.channelPinnedPostCountsCache = utils.NewLruWithParams(CHANNEL_PINNEDPOSTS_COUNTS_CACHE_SIZE, "ChannelPinnedPostsCounts", CHANNEL_PINNEDPOSTS_COUNTS_CACHE_SEC, model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_PINNEDPOSTS_COUNTS) localCacheStore.channelMemberCountsCache = utils.NewLruWithParams(CHANNEL_MEMBERS_COUNTS_CACHE_SIZE, "ChannelMemberCounts", CHANNEL_MEMBERS_COUNTS_CACHE_SEC, model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBER_COUNTS) localCacheStore.channelGuestCountCache = utils.NewLruWithParams(CHANNEL_GUEST_COUNT_CACHE_SIZE, "ChannelGuestsCount", CHANNEL_GUEST_COUNT_CACHE_SEC, model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_GUEST_COUNT) localCacheStore.channel = LocalCacheChannelStore{ChannelStore: baseStore.Channel(), rootStore: &localCacheStore} @@ -97,6 +102,7 @@ func NewLocalCacheLayer(baseStore store.Store, metrics einterfaces.MetricsInterf cluster.RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_WEBHOOKS, localCacheStore.webhook.handleClusterInvalidateWebhook) cluster.RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_EMOJIS_BY_ID, localCacheStore.emoji.handleClusterInvalidateEmojiById) cluster.RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_EMOJIS_ID_BY_NAME, localCacheStore.emoji.handleClusterInvalidateEmojiIdByName) + cluster.RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_PINNEDPOSTS_COUNTS, localCacheStore.channel.handleClusterInvalidateChannelPinnedPostCount) cluster.RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_MEMBER_COUNTS, localCacheStore.channel.handleClusterInvalidateChannelMemberCounts) cluster.RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_CHANNEL_GUEST_COUNT, localCacheStore.channel.handleClusterInvalidateChannelGuestCounts) cluster.RegisterClusterMessageHandler(model.CLUSTER_EVENT_INVALIDATE_CACHE_FOR_LAST_POSTS, localCacheStore.post.handleClusterInvalidateLastPosts) @@ -191,6 +197,7 @@ func (s *LocalCacheStore) Invalidate() { s.doClearCacheCluster(s.emojiCacheById) s.doClearCacheCluster(s.emojiIdCacheByName) s.doClearCacheCluster(s.channelMemberCountsCache) + s.doClearCacheCluster(s.channelPinnedPostCountsCache) s.doClearCacheCluster(s.channelGuestCountCache) s.doClearCacheCluster(s.postLastPostsCache) s.doClearCacheCluster(s.userProfileByIdsCache) diff --git a/store/localcachelayer/main_test.go b/store/localcachelayer/main_test.go index 4ed6984264..395b80b140 100644 --- a/store/localcachelayer/main_test.go +++ b/store/localcachelayer/main_test.go @@ -67,6 +67,10 @@ func getMockStore() *mocks.Store { mockChannelStore.On("GetGuestCount", "id", false).Return(mockGuestCount, nil) mockStore.On("Channel").Return(&mockChannelStore) + mockPinnedPostsCount := int64(10) + mockChannelStore.On("GetPinnedPostCount", "id", true).Return(mockPinnedPostsCount, nil) + mockChannelStore.On("GetPinnedPostCount", "id", false).Return(mockPinnedPostsCount, nil) + fakePosts := &model.PostList{} fakeOptions := model.GetPostsOptions{ChannelId: "123", PerPage: 30} mockPostStore := mocks.PostStore{} diff --git a/store/sqlstore/channel_store.go b/store/sqlstore/channel_store.go index d894e50941..86d3fceb2a 100644 --- a/store/sqlstore/channel_store.go +++ b/store/sqlstore/channel_store.go @@ -29,9 +29,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_PINNEDPOSTS_COUNTS_CACHE_SIZE = model.CHANNEL_CACHE_SIZE - CHANNEL_PINNEDPOSTS_COUNTS_CACHE_SEC = 1800 // 30 mins - CHANNEL_CACHE_SEC = 900 // 15 mins ) @@ -277,21 +274,18 @@ type publicChannel struct { Purpose string `json:"purpose"` } -var channelPinnedPostCountsCache = utils.NewLru(CHANNEL_PINNEDPOSTS_COUNTS_CACHE_SIZE) var allChannelMembersForUserCache = utils.NewLru(ALL_CHANNEL_MEMBERS_FOR_USER_CACHE_SIZE) 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) func (s SqlChannelStore) ClearCaches() { - channelPinnedPostCountsCache.Purge() allChannelMembersForUserCache.Purge() allChannelMembersNotifyPropsForChannelCache.Purge() channelCache.Purge() channelByNameCache.Purge() if s.metrics != nil { - s.metrics.IncrementMemCacheInvalidationCounter("Channel Pinned Post Counts - Purge") s.metrics.IncrementMemCacheInvalidationCounter("All Channel Members for User - Purge") s.metrics.IncrementMemCacheInvalidationCounter("All Channel Members Notify Props for Channel - Purge") s.metrics.IncrementMemCacheInvalidationCounter("Channel - Purge") @@ -1600,46 +1594,9 @@ func (s SqlChannelStore) GetMemberCount(channelId string, allowFromCache bool) ( } func (s SqlChannelStore) InvalidatePinnedPostCount(channelId string) { - channelPinnedPostCountsCache.Remove(channelId) - if s.metrics != nil { - s.metrics.IncrementMemCacheInvalidationCounter("Channel Pinned Post Counts - Remove by ChannelId") - } -} - -func (s SqlChannelStore) GetPinnedPostCountFromCache(channelId string) int64 { - if cacheItem, ok := channelPinnedPostCountsCache.Get(channelId); ok { - if s.metrics != nil { - s.metrics.IncrementMemCacheHitCounter("Channel Pinned Post Counts") - } - return cacheItem.(int64) - } - - if s.metrics != nil { - s.metrics.IncrementMemCacheMissCounter("Channel Pinned Post Counts") - } - - count, err := s.GetPinnedPostCount(channelId, true) - if err != nil { - return 0 - } - - return count } func (s SqlChannelStore) GetPinnedPostCount(channelId string, allowFromCache bool) (int64, *model.AppError) { - if allowFromCache { - if cacheItem, ok := channelPinnedPostCountsCache.Get(channelId); ok { - if s.metrics != nil { - s.metrics.IncrementMemCacheHitCounter("Channel Pinned Post Counts") - } - return cacheItem.(int64), nil - } - } - - if s.metrics != nil { - s.metrics.IncrementMemCacheMissCounter("Channel Pinned Post Counts") - } - count, err := s.GetReplica().SelectInt(` SELECT count(*) FROM Posts @@ -1652,10 +1609,6 @@ func (s SqlChannelStore) GetPinnedPostCount(channelId string, allowFromCache boo return 0, model.NewAppError("SqlChannelStore.GetPinnedPostCount", "store.sql_channel.get_pinnedpost_count.app_error", nil, "channel_id="+channelId+", "+err.Error(), http.StatusInternalServerError) } - if allowFromCache { - channelPinnedPostCountsCache.AddWithExpiresInSecs(channelId, count, CHANNEL_PINNEDPOSTS_COUNTS_CACHE_SEC) - } - return count, nil } diff --git a/store/store.go b/store/store.go index 242628ae02..653b17c3eb 100644 --- a/store/store.go +++ b/store/store.go @@ -157,7 +157,6 @@ type ChannelStore interface { GetMemberCountFromCache(channelId string) int64 GetMemberCount(channelId string, allowFromCache bool) (int64, *model.AppError) InvalidatePinnedPostCount(channelId string) - GetPinnedPostCountFromCache(channelId string) int64 GetPinnedPostCount(channelId string, allowFromCache bool) (int64, *model.AppError) InvalidateGuestCount(channelId string) GetGuestCount(channelId string, allowFromCache bool) (int64, *model.AppError) diff --git a/store/storetest/channel_store.go b/store/storetest/channel_store.go index 228fe09aa8..e981305e73 100644 --- a/store/storetest/channel_store.go +++ b/store/storetest/channel_store.go @@ -3200,12 +3200,6 @@ func testChannelStoreGetPinnedPostCount(t *testing.T, ss store.Store) { require.Nil(t, errGet, errGet) require.EqualValues(t, 2, count, "didn't return right count") - require.EqualValues( - t, - 2, - ss.Channel().GetPinnedPostCountFromCache(o1.Id), - "should have saved 2 pinned post count") - ch2 := &model.Channel{ TeamId: model.NewId(), DisplayName: "Name", @@ -3233,12 +3227,6 @@ func testChannelStoreGetPinnedPostCount(t *testing.T, ss store.Store) { count, errGet = ss.Channel().GetPinnedPostCount(o2.Id, true) require.Nil(t, errGet, errGet) require.EqualValues(t, 0, count, "should return 0") - - require.EqualValues( - t, - 0, - ss.Channel().GetPinnedPostCountFromCache(o2.Id), - "should have saved 0 pinned post count") } func testChannelStoreMaxChannelsPerTeam(t *testing.T, ss store.Store) { diff --git a/store/storetest/mocks/ChannelStore.go b/store/storetest/mocks/ChannelStore.go index 047e4b9d8c..8b02a73360 100644 --- a/store/storetest/mocks/ChannelStore.go +++ b/store/storetest/mocks/ChannelStore.go @@ -646,13 +646,13 @@ func (_m *ChannelStore) GetChannelsByScheme(schemeId string, offset int, limit i return r0, r1 } -// GetDeleted provides a mock function with given fields: team_id, offset, limit +// GetDeleted provides a mock function with given fields: team_id, offset, limit, userId func (_m *ChannelStore) GetDeleted(team_id string, offset int, limit int, userId string) (*model.ChannelList, *model.AppError) { - ret := _m.Called(team_id, offset, limit) + ret := _m.Called(team_id, offset, limit, userId) var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, int, int) *model.ChannelList); ok { - r0 = rf(team_id, offset, limit) + if rf, ok := ret.Get(0).(func(string, int, int, string) *model.ChannelList); ok { + r0 = rf(team_id, offset, limit, userId) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*model.ChannelList) @@ -660,8 +660,8 @@ func (_m *ChannelStore) GetDeleted(team_id string, offset int, limit int, userId } var r1 *model.AppError - if rf, ok := ret.Get(1).(func(string, int, int) *model.AppError); ok { - r1 = rf(team_id, offset, limit) + if rf, ok := ret.Get(1).(func(string, int, int, string) *model.AppError); ok { + r1 = rf(team_id, offset, limit, userId) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(*model.AppError) @@ -1018,20 +1018,6 @@ func (_m *ChannelStore) GetPinnedPostCount(channelId string, allowFromCache bool return r0, r1 } -// GetPinnedPostCountFromCache provides a mock function with given fields: channelId -func (_m *ChannelStore) GetPinnedPostCountFromCache(channelId string) int64 { - ret := _m.Called(channelId) - - var r0 int64 - if rf, ok := ret.Get(0).(func(string) int64); ok { - r0 = rf(channelId) - } else { - r0 = ret.Get(0).(int64) - } - - return r0 -} - // GetPinnedPosts provides a mock function with given fields: channelId func (_m *ChannelStore) GetPinnedPosts(channelId string) (*model.PostList, *model.AppError) { ret := _m.Called(channelId) @@ -1452,16 +1438,48 @@ func (_m *ChannelStore) SearchAllChannels(term string, opts store.ChannelSearchO } } - var r1 *model.AppError - if rf, ok := ret.Get(1).(func(string, store.ChannelSearchOpts) *model.AppError); ok { + var r1 int64 + if rf, ok := ret.Get(1).(func(string, store.ChannelSearchOpts) int64); ok { r1 = rf(term, opts) + } else { + r1 = ret.Get(1).(int64) + } + + var r2 *model.AppError + if rf, ok := ret.Get(2).(func(string, store.ChannelSearchOpts) *model.AppError); ok { + r2 = rf(term, opts) + } else { + if ret.Get(2) != nil { + r2 = ret.Get(2).(*model.AppError) + } + } + + return r0, r1, r2 +} + +// SearchArchivedInTeam provides a mock function with given fields: teamId, term, userId +func (_m *ChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) { + ret := _m.Called(teamId, term, userId) + + var r0 *model.ChannelList + if rf, ok := ret.Get(0).(func(string, string, string) *model.ChannelList); ok { + r0 = rf(teamId, term, userId) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.ChannelList) + } + } + + var r1 *model.AppError + if rf, ok := ret.Get(1).(func(string, string, string) *model.AppError); ok { + r1 = rf(teamId, term, userId) } else { if ret.Get(1) != nil { r1 = ret.Get(1).(*model.AppError) } } - return r0, 0, r1 + return r0, r1 } // SearchForUserInTeam provides a mock function with given fields: userId, teamId, term, includeDeleted @@ -1539,31 +1557,6 @@ func (_m *ChannelStore) SearchInTeam(teamId string, term string, includeDeleted return r0, r1 } -// SearchArchivedInTeam provides a mock function with given fields: teamId, term, userId -func (_m *ChannelStore) SearchArchivedInTeam(teamId string, term string, userId string) (*model.ChannelList, *model.AppError) { - ret := _m.Called(teamId, term, userId) - - var r0 *model.ChannelList - if rf, ok := ret.Get(0).(func(string, string, string) *model.ChannelList); ok { - r0 = rf(teamId, term, userId) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).(*model.ChannelList) - } - } - - var r1 *model.AppError - if rf, ok := ret.Get(1).(func(string, string, string) *model.AppError); ok { - r1 = rf(teamId, term, userId) - } else { - if ret.Get(1) != nil { - r1 = ret.Get(1).(*model.AppError) - } - } - - return r0, r1 -} - // SearchMore provides a mock function with given fields: userId, teamId, term func (_m *ChannelStore) SearchMore(userId string, teamId string, term string) (*model.ChannelList, *model.AppError) { ret := _m.Called(userId, teamId, term) diff --git a/store/timer_layer.go b/store/timer_layer.go index 084eb9c795..599cbbedfd 100644 --- a/store/timer_layer.go +++ b/store/timer_layer.go @@ -1144,22 +1144,6 @@ func (s *TimerLayerChannelStore) GetPinnedPostCount(channelId string, allowFromC return resultVar0, resultVar1 } -func (s *TimerLayerChannelStore) GetPinnedPostCountFromCache(channelId string) int64 { - start := timemodule.Now() - - resultVar0 := s.ChannelStore.GetPinnedPostCountFromCache(channelId) - - elapsed := float64(timemodule.Since(start)) / float64(timemodule.Second) - if s.Root.Metrics != nil { - success := "false" - if true { - success = "true" - } - s.Root.Metrics.ObserveStoreMethodDuration("ChannelStore.GetPinnedPostCountFromCache", success, elapsed) - } - return resultVar0 -} - func (s *TimerLayerChannelStore) GetPinnedPosts(channelId string) (*model.PostList, *model.AppError) { start := timemodule.Now()