Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Siyuan Liu
2020-07-18 01:01:06 -07:00
коммит произвёл GitHub
родитель 3f46cf6f60
Коммит c7f7bef9ec
22 изменённых файлов: 111 добавлений и 578 удалений

Просмотреть файл

@@ -76,7 +76,7 @@ func setupTestHelper(dbStore store.Store, enterprise bool, includeCacheLayer boo
if includeCacheLayer {
// Adds the cache layer to the test store
s.Store = localcachelayer.NewLocalCacheLayer(s.Store, s.Metrics, s.Cluster, s.CacheProvider2)
s.Store = localcachelayer.NewLocalCacheLayer(s.Store, s.Metrics, s.Cluster, s.CacheProvider)
}
th := &TestHelper{

Просмотреть файл

@@ -15,7 +15,7 @@ import (
"github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v5/services/cache2"
"github.com/mattermost/mattermost-server/v5/services/cache"
"github.com/mattermost/mattermost-server/v5/store"
"github.com/mattermost/mattermost-server/v5/utils"
)
@@ -121,7 +121,7 @@ func (a *App) deduplicateCreatePost(post *model.Post) (foundPost *model.Post, er
// it hasn't previously been seen.
var postId string
nErr := a.Srv().seenPendingPostIdsCache.Get(post.PendingPostId, &postId)
if nErr == cache2.ErrKeyNotFound {
if nErr == cache.ErrKeyNotFound {
a.Srv().seenPendingPostIdsCache.SetWithExpiry(post.PendingPostId, unknownPostId, PENDING_POST_IDS_CACHE_TTL)
return nil, nil
}

Просмотреть файл

@@ -17,7 +17,7 @@ import (
"github.com/dyatlov/go-opengraph/opengraph"
"github.com/mattermost/mattermost-server/v5/mlog"
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/services/cache2"
"github.com/mattermost/mattermost-server/v5/services/cache"
"github.com/mattermost/mattermost-server/v5/utils/imgutils"
"github.com/mattermost/mattermost-server/v5/utils/markdown"
)
@@ -31,7 +31,7 @@ const LINK_CACHE_SIZE = 10000
const LINK_CACHE_DURATION = 1 * time.Hour
const MaxMetadataImageSize = MaxOpenGraphResponseSize
var linkCache = cache2.NewLRU(&cache2.LRUOptions{
var linkCache = cache.NewLRU(&cache.LRUOptions{
Size: LINK_CACHE_SIZE,
})

Просмотреть файл

@@ -36,8 +36,6 @@ import (
"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v5/services/cache"
"github.com/mattermost/mattermost-server/v5/services/cache/lru"
"github.com/mattermost/mattermost-server/v5/services/cache2"
"github.com/mattermost/mattermost-server/v5/services/filesstore"
"github.com/mattermost/mattermost-server/v5/services/httpservice"
"github.com/mattermost/mattermost-server/v5/services/imageproxy"
@@ -110,9 +108,9 @@ type Server struct {
newStore func() store.Store
htmlTemplateWatcher *utils.HTMLTemplateWatcher
sessionCache cache2.Cache
seenPendingPostIdsCache cache2.Cache
statusCache cache2.Cache
sessionCache cache.Cache
seenPendingPostIdsCache cache.Cache
statusCache cache.Cache
configListenerId string
licenseListenerId string
logListenerId string
@@ -163,8 +161,6 @@ type Server struct {
CacheProvider cache.Provider
CacheProvider2 cache2.Provider
tracer *tracing.Tracer
timestampLastDiagnosticSent time.Time
}
@@ -247,22 +243,18 @@ func NewServer(options ...Option) (*Server, error) {
// at the moment we only have this implementation
// in the future the cache provider will be built based on the loaded config
s.CacheProvider = new(lru.CacheProvider)
s.CacheProvider.Connect()
s.CacheProvider2 = cache2.NewProvider()
if err := s.CacheProvider2.Connect(); err != nil {
s.CacheProvider = cache.NewProvider()
if err := s.CacheProvider.Connect(); err != nil {
return nil, errors.Wrapf(err, "Unable to connect to cache provider")
}
s.sessionCache = s.CacheProvider2.NewCache(&cache2.CacheOptions{
s.sessionCache = s.CacheProvider.NewCache(&cache.CacheOptions{
Size: model.SESSION_CACHE_SIZE,
})
s.seenPendingPostIdsCache = s.CacheProvider2.NewCache(&cache2.CacheOptions{
s.seenPendingPostIdsCache = s.CacheProvider.NewCache(&cache.CacheOptions{
Size: PENDING_POST_IDS_CACHE_SIZE,
})
s.statusCache = s.CacheProvider2.NewCache(&cache2.CacheOptions{
s.statusCache = s.CacheProvider.NewCache(&cache.CacheOptions{
Size: model.STATUS_CACHE_SIZE,
})
@@ -303,7 +295,7 @@ func NewServer(options ...Option) (*Server, error) {
s.sqlStore,
s.Metrics,
s.Cluster,
s.CacheProvider2,
s.CacheProvider,
),
s.SearchEngine,
s.Config(),
@@ -702,11 +694,7 @@ func (s *Server) Shutdown() error {
}
if s.CacheProvider != nil {
s.CacheProvider.Close()
}
if s.CacheProvider2 != nil {
if err = s.CacheProvider2.Close(); err != nil {
if err = s.CacheProvider.Close(); err != nil {
mlog.Error("Unable to cleanly shutdown cache", mlog.Err(err))
}
}