While using Redis, there is no need to invalidate and then update the new count from the DB when we know the exact number it is going to be incremented or decremented by. In that case, we can directly use Redis primitives to update the cache and prevent yet another DB query. To achieve this, we modify the LRU cache get/set paths slightly to not marshal into byte slices for *int64 values. This is needed for Redis to operate the INCR/DECR commands. https://mattermost.atlassian.net/browse/MM-59933 ```release-note NONE ``` Co-authored-by: Mattermost Build <build@mattermost.com>
250 строки
5.2 KiB
Go
250 строки
5.2 KiB
Go
// Code generated by mockery v2.42.2. DO NOT EDIT.
|
|
|
|
// Regenerate this file using `make cache-mocks`.
|
|
|
|
package mocks
|
|
|
|
import (
|
|
time "time"
|
|
|
|
model "github.com/mattermost/mattermost/server/public/model"
|
|
mock "github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
// ExternalCache is an autogenerated mock type for the ExternalCache type
|
|
type ExternalCache struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// Decrement provides a mock function with given fields: key, val
|
|
func (_m *ExternalCache) Decrement(key string, val int) error {
|
|
ret := _m.Called(key, val)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Decrement")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(string, int) error); ok {
|
|
r0 = rf(key, val)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Get provides a mock function with given fields: key, value
|
|
func (_m *ExternalCache) Get(key string, value interface{}) error {
|
|
ret := _m.Called(key, value)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Get")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(string, interface{}) error); ok {
|
|
r0 = rf(key, value)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetInvalidateClusterEvent provides a mock function with given fields:
|
|
func (_m *ExternalCache) GetInvalidateClusterEvent() model.ClusterEvent {
|
|
ret := _m.Called()
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for GetInvalidateClusterEvent")
|
|
}
|
|
|
|
var r0 model.ClusterEvent
|
|
if rf, ok := ret.Get(0).(func() model.ClusterEvent); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Get(0).(model.ClusterEvent)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetMulti provides a mock function with given fields: keys, values
|
|
func (_m *ExternalCache) GetMulti(keys []string, values []interface{}) []error {
|
|
ret := _m.Called(keys, values)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for GetMulti")
|
|
}
|
|
|
|
var r0 []error
|
|
if rf, ok := ret.Get(0).(func([]string, []interface{}) []error); ok {
|
|
r0 = rf(keys, values)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).([]error)
|
|
}
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Increment provides a mock function with given fields: key, val
|
|
func (_m *ExternalCache) Increment(key string, val int) error {
|
|
ret := _m.Called(key, val)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Increment")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(string, int) error); ok {
|
|
r0 = rf(key, val)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Name provides a mock function with given fields:
|
|
func (_m *ExternalCache) Name() string {
|
|
ret := _m.Called()
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Name")
|
|
}
|
|
|
|
var r0 string
|
|
if rf, ok := ret.Get(0).(func() string); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Get(0).(string)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Purge provides a mock function with given fields:
|
|
func (_m *ExternalCache) Purge() error {
|
|
ret := _m.Called()
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Purge")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func() error); ok {
|
|
r0 = rf()
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Remove provides a mock function with given fields: key
|
|
func (_m *ExternalCache) Remove(key string) error {
|
|
ret := _m.Called(key)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Remove")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(string) error); ok {
|
|
r0 = rf(key)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// RemoveMulti provides a mock function with given fields: keys
|
|
func (_m *ExternalCache) RemoveMulti(keys []string) error {
|
|
ret := _m.Called(keys)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for RemoveMulti")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func([]string) error); ok {
|
|
r0 = rf(keys)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// Scan provides a mock function with given fields: f
|
|
func (_m *ExternalCache) Scan(f func([]string) error) error {
|
|
ret := _m.Called(f)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for Scan")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(func([]string) error) error); ok {
|
|
r0 = rf(f)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// SetWithDefaultExpiry provides a mock function with given fields: key, value
|
|
func (_m *ExternalCache) SetWithDefaultExpiry(key string, value interface{}) error {
|
|
ret := _m.Called(key, value)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for SetWithDefaultExpiry")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(string, interface{}) error); ok {
|
|
r0 = rf(key, value)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// SetWithExpiry provides a mock function with given fields: key, value, ttl
|
|
func (_m *ExternalCache) SetWithExpiry(key string, value interface{}, ttl time.Duration) error {
|
|
ret := _m.Called(key, value, ttl)
|
|
|
|
if len(ret) == 0 {
|
|
panic("no return value specified for SetWithExpiry")
|
|
}
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(string, interface{}, time.Duration) error); ok {
|
|
r0 = rf(key, value, ttl)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// NewExternalCache creates a new instance of ExternalCache. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
|
// The first argument is typically a *testing.T value.
|
|
func NewExternalCache(t interface {
|
|
mock.TestingT
|
|
Cleanup(func())
|
|
}) *ExternalCache {
|
|
mock := &ExternalCache{}
|
|
mock.Mock.Test(t)
|
|
|
|
t.Cleanup(func() { mock.AssertExpectations(t) })
|
|
|
|
return mock
|
|
}
|