MM-32693: Use master when emoji_layer is invalidated (#16951)
We add a map which tracks invalidations to the emoji caches and use master whenever a fresh item is fetched from DB. https://mattermost.atlassian.net/browse/MM-32693 ```release-note NONE ``` Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
33c8b0ad73
Коммит
6dcbad049c
@@ -4,6 +4,7 @@
|
||||
package storetest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -80,12 +81,12 @@ func testEmojiGet(t *testing.T, ss store.Store) {
|
||||
}()
|
||||
|
||||
for _, emoji := range emojis {
|
||||
_, err := ss.Emoji().Get(emoji.Id, false)
|
||||
_, err := ss.Emoji().Get(context.Background(), emoji.Id, false)
|
||||
require.NoErrorf(t, err, "failed to get emoji with id %v", emoji.Id)
|
||||
}
|
||||
|
||||
for _, emoji := range emojis {
|
||||
_, err := ss.Emoji().Get(emoji.Id, true)
|
||||
_, err := ss.Emoji().Get(context.Background(), emoji.Id, true)
|
||||
require.NoErrorf(t, err, "failed to get emoji with id %v", emoji.Id)
|
||||
}
|
||||
}
|
||||
@@ -119,7 +120,7 @@ func testEmojiGetByName(t *testing.T, ss store.Store) {
|
||||
}()
|
||||
|
||||
for _, emoji := range emojis {
|
||||
_, err := ss.Emoji().GetByName(emoji.Name, true)
|
||||
_, err := ss.Emoji().GetByName(context.Background(), emoji.Name, true)
|
||||
require.NoErrorf(t, err, "failed to get emoji with name %v", emoji.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
package mocks
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
model "github.com/mattermost/mattermost-server/v5/model"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
@@ -28,13 +30,13 @@ func (_m *EmojiStore) Delete(emoji *model.Emoji, time int64) error {
|
||||
return r0
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: id, allowFromCache
|
||||
func (_m *EmojiStore) Get(id string, allowFromCache bool) (*model.Emoji, error) {
|
||||
ret := _m.Called(id, allowFromCache)
|
||||
// Get provides a mock function with given fields: ctx, id, allowFromCache
|
||||
func (_m *EmojiStore) Get(ctx context.Context, id string, allowFromCache bool) (*model.Emoji, error) {
|
||||
ret := _m.Called(ctx, id, allowFromCache)
|
||||
|
||||
var r0 *model.Emoji
|
||||
if rf, ok := ret.Get(0).(func(string, bool) *model.Emoji); ok {
|
||||
r0 = rf(id, allowFromCache)
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, bool) *model.Emoji); ok {
|
||||
r0 = rf(ctx, id, allowFromCache)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.Emoji)
|
||||
@@ -42,8 +44,8 @@ func (_m *EmojiStore) Get(id string, allowFromCache bool) (*model.Emoji, error)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, bool) error); ok {
|
||||
r1 = rf(id, allowFromCache)
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, bool) error); ok {
|
||||
r1 = rf(ctx, id, allowFromCache)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
@@ -51,13 +53,13 @@ func (_m *EmojiStore) Get(id string, allowFromCache bool) (*model.Emoji, error)
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetByName provides a mock function with given fields: name, allowFromCache
|
||||
func (_m *EmojiStore) GetByName(name string, allowFromCache bool) (*model.Emoji, error) {
|
||||
ret := _m.Called(name, allowFromCache)
|
||||
// GetByName provides a mock function with given fields: ctx, name, allowFromCache
|
||||
func (_m *EmojiStore) GetByName(ctx context.Context, name string, allowFromCache bool) (*model.Emoji, error) {
|
||||
ret := _m.Called(ctx, name, allowFromCache)
|
||||
|
||||
var r0 *model.Emoji
|
||||
if rf, ok := ret.Get(0).(func(string, bool) *model.Emoji); ok {
|
||||
r0 = rf(name, allowFromCache)
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string, bool) *model.Emoji); ok {
|
||||
r0 = rf(ctx, name, allowFromCache)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.Emoji)
|
||||
@@ -65,8 +67,8 @@ func (_m *EmojiStore) GetByName(name string, allowFromCache bool) (*model.Emoji,
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, bool) error); ok {
|
||||
r1 = rf(name, allowFromCache)
|
||||
if rf, ok := ret.Get(1).(func(context.Context, string, bool) error); ok {
|
||||
r1 = rf(ctx, name, allowFromCache)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user