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 удалений

52
services/cache/provider.go поставляемый Обычный файл
Просмотреть файл

@@ -0,0 +1,52 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package cache
import "time"
// CacheOptions contains options for initializaing a cache
type CacheOptions struct {
Size int
DefaultExpiry time.Duration
Name string
InvalidateClusterEvent string
}
// Provider is a provider for Cache
type Provider interface {
// NewCache creates a new cache with given options.
NewCache(opts *CacheOptions) Cache
// Connect opens a new connection to the cache using specific provider parameters.
Connect() error
// Close releases any resources used by the cache provider.
Close() error
}
type cacheProvider struct {
}
// NewProvider creates a new CacheProvider
func NewProvider() Provider {
return &cacheProvider{}
}
// NewCache creates a new cache with given opts
func (c *cacheProvider) NewCache(opts *CacheOptions) Cache {
return NewLRU(&LRUOptions{
Name: opts.Name,
Size: opts.Size,
DefaultExpiry: opts.DefaultExpiry,
InvalidateClusterEvent: opts.InvalidateClusterEvent,
})
}
// Connect opens a new connection to the cache using specific provider parameters.
func (c *cacheProvider) Connect() error {
return nil
}
// Close releases any resources used by the cache provider.
func (c *cacheProvider) Close() error {
return nil
}