github.com/qichengzx/mattermost-server@v4.5.1-0.20180604164826-2c75247c97d0+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) SchemeDelete(ctx context.Context, schemeId string, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { 40 defer s.doInvalidateCacheCluster(s.schemeCache, schemeId) 41 defer s.doClearCacheCluster(s.roleCache) 42 43 return s.Next().SchemeDelete(ctx, schemeId, hints...) 44 } 45 46 func (s *LocalCacheSupplier) SchemeGetAllPage(ctx context.Context, scope string, offset int, limit int, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { 47 return s.Next().SchemeGetAllPage(ctx, scope, offset, limit, hints...) 48 } 49 50 func (s *LocalCacheSupplier) SchemePermanentDeleteAll(ctx context.Context, hints ...LayeredStoreHint) *LayeredStoreSupplierResult { 51 defer s.doClearCacheCluster(s.schemeCache) 52 53 return s.Next().SchemePermanentDeleteAll(ctx, hints...) 54 }