Documentation ¶
Index ¶
- Constants
- Variables
- func Initialize(ctx context.Context, cacheOpt *Config, storage store.Store) error
- func RegisterCache(name string, index types.CacheIndex)
- func Run(cacheMgr *CacheManager, ctx context.Context) error
- func SetCacheConfig(conf *Config)
- type CacheManager
- func (nc *CacheManager) AuthStrategy() types.StrategyCache
- func (nc *CacheManager) CL5() types.L5Cache
- func (nc *CacheManager) CircuitBreaker() types.CircuitBreakerCache
- func (nc *CacheManager) Clear() error
- func (nc *CacheManager) Client() types.ClientCache
- func (nc *CacheManager) Close() error
- func (nc *CacheManager) ConfigFile() types.ConfigFileCache
- func (nc *CacheManager) ConfigGroup() types.ConfigGroupCache
- func (nc *CacheManager) FaultDetector() types.FaultDetectCache
- func (nc *CacheManager) GetCacher(cacheIndex types.CacheIndex) types.Cache
- func (nc *CacheManager) GetStore() store.Store
- func (nc *CacheManager) GetUpdateCacheInterval() time.Duration
- func (nc *CacheManager) Gray() types.GrayCache
- func (nc *CacheManager) Initialize() error
- func (nc *CacheManager) Instance() types.InstanceCache
- func (nc *CacheManager) Namespace() types.NamespaceCache
- func (nc *CacheManager) OpenResourceCache(entries ...types.ConfigEntry) error
- func (nc *CacheManager) RateLimit() types.RateLimitCache
- func (nc *CacheManager) RegisterCacher(cacheType types.CacheIndex, item types.Cache)
- func (nc *CacheManager) RoutingConfig() types.RoutingConfigCache
- func (nc *CacheManager) Service() types.ServiceCache
- func (nc *CacheManager) ServiceContract() types.ServiceContractCache
- func (nc *CacheManager) Start(ctx context.Context) error
- func (nc *CacheManager) TestUpdate() error
- func (nc *CacheManager) User() types.UserCache
- type Config
Constants ¶
const ( // UpdateCacheInterval 缓存更新时间间隔 UpdateCacheInterval = 1 * time.Second )
Variables ¶
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 ¶
Initialize 初始化
Types ¶
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager 名字服务缓存
func (*CacheManager) AuthStrategy ¶
func (nc *CacheManager) AuthStrategy() types.StrategyCache
AuthStrategy Get authentication cache information
func (*CacheManager) CircuitBreaker ¶
func (nc *CacheManager) CircuitBreaker() types.CircuitBreakerCache
CircuitBreaker 获取熔断规则缓存信息
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) 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