cache

package
v1.18.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 15 Imported by: 6

Documentation

Index

Constants

View Source
const (
	// UpdateCacheInterval 缓存更新时间间隔
	UpdateCacheInterval = 1 * time.Second
)

Variables

View Source
var (
	TestCacheInitialize = func(ctx context.Context, cacheOpt *Config, storage store.Store) (*CacheManager, error) {
		mgr, err := newCacheManager(ctx, cacheOpt, storage)
		if err != nil {
			return nil, err
		}
		return mgr, err
	}

	TestRun = func(ctx context.Context, mgr *CacheManager) error {
		if err := Run(mgr, ctx); err != nil {
			return err
		}
		return nil
	}
)

TestCacheInitialize 由于某一些模块依赖Cache,但是由于Cache模块初始化采用sync.Once,会导致单元测试之间Cache存在脏数据问题,因此为了确保单 元测试能够正常执行,这里将 cache.initialize 方法导出并命名为 TestCacheInitialize,仅用于单元测试初始化一个完整的 CacheManager

Functions

func Initialize

func Initialize(ctx context.Context, cacheOpt *Config, storage store.Store) error

Initialize 初始化

func RegisterCache

func RegisterCache(name string, index types.CacheIndex)

RegisterCache 注册缓存资源

func Run

func Run(cacheMgr *CacheManager, ctx context.Context) error

func SetCacheConfig

func SetCacheConfig(conf *Config)

SetCacheConfig 设置缓存配置

Types

type CacheManager

type CacheManager struct {
	// contains filtered or unexported fields
}

CacheManager 名字服务缓存

func GetCacheManager

func GetCacheManager() (*CacheManager, error)

GetCacheManager

func (*CacheManager) AuthStrategy

func (nc *CacheManager) AuthStrategy() types.StrategyCache

AuthStrategy Get authentication cache information

func (*CacheManager) CL5

func (nc *CacheManager) CL5() types.L5Cache

CL5 获取l5缓存信息

func (*CacheManager) CircuitBreaker

func (nc *CacheManager) CircuitBreaker() types.CircuitBreakerCache

CircuitBreaker 获取熔断规则缓存信息

func (*CacheManager) Clear

func (nc *CacheManager) Clear() error

Clear 主动清除缓存数据

func (*CacheManager) Client

func (nc *CacheManager) Client() types.ClientCache

Client Get client cache information

func (*CacheManager) Close added in v1.17.3

func (nc *CacheManager) Close() error

Close 关闭所有的 Cache 缓存

func (*CacheManager) ConfigFile

func (nc *CacheManager) ConfigFile() types.ConfigFileCache

ConfigFile get config file cache information

func (*CacheManager) ConfigGroup added in v1.17.3

func (nc *CacheManager) ConfigGroup() types.ConfigGroupCache

ConfigGroup get config group cache information

func (*CacheManager) FaultDetector added in v1.14.0

func (nc *CacheManager) FaultDetector() types.FaultDetectCache

FaultDetector 获取探测规则缓存信息

func (*CacheManager) GetCacher added in v1.17.3

func (nc *CacheManager) GetCacher(cacheIndex types.CacheIndex) types.Cache

GetCacher get types.Cache impl

func (*CacheManager) GetStore

func (nc *CacheManager) GetStore() store.Store

GetStore get store

func (*CacheManager) GetUpdateCacheInterval

func (nc *CacheManager) GetUpdateCacheInterval() time.Duration

GetUpdateCacheInterval 获取当前cache的更新间隔

func (*CacheManager) Gray added in v1.18.0

func (nc *CacheManager) Gray() types.GrayCache

Gray get Gray cache information

func (*CacheManager) Initialize added in v1.17.3

func (nc *CacheManager) Initialize() error

Initialize 缓存对象初始化

func (*CacheManager) Instance

func (nc *CacheManager) Instance() types.InstanceCache

Instance 获取Instance缓存信息

func (*CacheManager) Namespace

func (nc *CacheManager) Namespace() types.NamespaceCache

Namespace Get namespace cache information

func (*CacheManager) OpenResourceCache added in v1.18.0

func (nc *CacheManager) OpenResourceCache(entries ...types.ConfigEntry) error

OpenResourceCache 开启资源缓存

func (*CacheManager) RateLimit

func (nc *CacheManager) RateLimit() types.RateLimitCache

RateLimit 获取限流规则缓存信息

func (*CacheManager) RegisterCacher added in v1.17.3

func (nc *CacheManager) RegisterCacher(cacheType types.CacheIndex, item types.Cache)

func (*CacheManager) RoutingConfig

func (nc *CacheManager) RoutingConfig() types.RoutingConfigCache

RoutingConfig 获取路由配置的缓存信息

func (*CacheManager) Service

func (nc *CacheManager) Service() types.ServiceCache

Service 获取Service缓存信息

func (*CacheManager) ServiceContract added in v1.18.0

func (nc *CacheManager) ServiceContract() types.ServiceContractCache

ServiceContract 获取服务契约缓存

func (*CacheManager) Start

func (nc *CacheManager) Start(ctx context.Context) error

Start 缓存对象启动协程,定时更新缓存

func (*CacheManager) TestUpdate added in v1.16.0

func (nc *CacheManager) TestUpdate() error

TestUpdate only for test

func (*CacheManager) User

func (nc *CacheManager) User() types.UserCache

User Get user information cache information

type Config

type Config struct {
	// DiffTime 设置拉取时间范围, [T1 - abs(DiffTime), T1]
	DiffTime time.Duration `yaml:"diffTime"`
}

Config 缓存配置

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL