github.com/mad-app/mattermost-server@v5.11.1+incompatible/store/local_cache_supplier_schemes.go (about) 1 // Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package store 5 6 import ( 7 "context" 8 9 "github.com/mattermost/mattermost-server/model" 10 ) 11 12 func (s *LocalCacheSupplier) handleClusterInvalidateScheme(msg *model.ClusterMessage) { 13 if msg.Data == CLEAR_CACHE_MESSAGE_DATA { 14 s.schemeCache.Purge() 15 } else { 16 s.schemeCache.Remove(msg.Data) 17 } 18 } 19 20 func (s *LocalCacheSupplier) SchemeSave(ctx context.Context, scheme *model.Scheme, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { 21 if len(scheme.Id) != 0 { 22 defer s.doInvalidateCacheCluster(s.schemeCache, scheme.Id) 23 } 24 return s.Next().SchemeSave(ctx, scheme, hints...) 25 } 26 27 func (s *LocalCacheSupplier) SchemeGet(ctx context.Context, schemeId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { 28 if result := s.doStandardReadCache(ctx, s.schemeCache, schemeId, hints...); result != nil { 29 return result 30 } 31 32 result := s.Next().SchemeGet(ctx, schemeId, hints...) 33 34 s.doStandardAddToCache(ctx, s.schemeCache, schemeId, result, hints...) 35 36 return result 37 } 38 39 func (s *LocalCacheSupplier) SchemeGetByName(ctx context.Context, schemeName string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { 40 return s.Next().SchemeGetByName(ctx, schemeName, hints...) 41 } 42 43 func (s *LocalCacheSupplier) SchemeDelete(ctx context.Context, schemeId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { 44 defer s.doInvalidateCacheCluster(s.schemeCache, schemeId) 45 defer s.doClearCacheCluster(s.roleCache) 46 47 return s.Next().SchemeDelete(ctx, schemeId, hints...) 48 } 49 50 func (s *LocalCacheSupplier) SchemeGetAllPage(ctx context.Context, scope string, offset int, limit int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { 51 return s.Next().SchemeGetAllPage(ctx, scope, offset, limit, hints...) 52 } 53 54 func (s *LocalCacheSupplier) SchemePermanentDeleteAll(ctx context.Context, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { 55 defer s.doClearCacheCluster(s.schemeCache) 56 defer s.doClearCacheCluster(s.roleCache) 57 58 return s.Next().SchemePermanentDeleteAll(ctx, hints...) 59 }