diff options
Diffstat (limited to 'store/local_cache_supplier_schemes.go')
-rw-r--r-- | store/local_cache_supplier_schemes.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/store/local_cache_supplier_schemes.go b/store/local_cache_supplier_schemes.go new file mode 100644 index 000000000..2a8f73a71 --- /dev/null +++ b/store/local_cache_supplier_schemes.go @@ -0,0 +1,44 @@ +// Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package store + +import ( + "context" + + "github.com/mattermost/mattermost-server/model" +) + +func (s *LocalCacheSupplier) handleClusterInvalidateScheme(msg *model.ClusterMessage) { + if msg.Data == CLEAR_CACHE_MESSAGE_DATA { + s.schemeCache.Purge() + } else { + s.schemeCache.Remove(msg.Data) + } +} + +func (s *LocalCacheSupplier) SchemeSave(ctx context.Context, scheme *model.Scheme, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { + if len(scheme.Id) != 0 { + defer s.doInvalidateCacheCluster(s.schemeCache, scheme.Id) + } + return s.Next().SchemeSave(ctx, scheme, hints...) +} + +func (s *LocalCacheSupplier) SchemeGet(ctx context.Context, schemeId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { + if result := s.doStandardReadCache(ctx, s.schemeCache, schemeId, hints...); result != nil { + return result + } + + result := s.Next().SchemeGet(ctx, schemeId, hints...) + + s.doStandardAddToCache(ctx, s.schemeCache, schemeId, result, hints...) + + return result +} + +func (s *LocalCacheSupplier) SchemeDelete(ctx context.Context, schemeId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { + defer s.doInvalidateCacheCluster(s.schemeCache, schemeId) + defer s.doClearCacheCluster(s.roleCache) + + return s.Next().SchemeDelete(ctx, schemeId, hints...) +} |