Documentation
¶
Index ¶
- type CacheRefreshService
- type ConfigValidator
- type ConfigurationCache
- func (c *ConfigurationCache) Clear()
- func (c *ConfigurationCache) Delete(key string)
- func (c *ConfigurationCache) Get(key string) (string, bool)
- func (c *ConfigurationCache) GetAll() map[string]string
- func (c *ConfigurationCache) Set(key, value string)
- func (c *ConfigurationCache) SetAll(configs map[string]string)
- func (c *ConfigurationCache) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheRefreshService ¶
type CacheRefreshService struct {
// contains filtered or unexported fields
}
CacheRefreshService 缓存刷新服务 定时从数据库加载所有配置到缓存
func NewCacheRefreshService ¶
func NewCacheRefreshService(cache *ConfigurationCache, dbEnt *ent.Client, logger logx.Logger) *CacheRefreshService
NewCacheRefreshService 创建缓存刷新服务
func (*CacheRefreshService) RefreshNow ¶
func (s *CacheRefreshService) RefreshNow(ctx context.Context)
RefreshNow 立即刷新缓存(用于 Create/Update/Delete 后调用)
func (*CacheRefreshService) Start ¶
func (s *CacheRefreshService) Start(ctx context.Context)
Start 启动缓存刷新服务
type ConfigValidator ¶
type ConfigValidator struct {
// contains filtered or unexported fields
}
ConfigValidator 封装了配置和CEL求值逻辑 支持 Program 缓存以提高性能
func NewConfigValidator ¶
func NewConfigValidator(cache *ConfigurationCache) (*ConfigValidator, error)
NewConfigValidator 创建一个新的验证器实例
func (*ConfigValidator) ClearProgramCache ¶
func (cv *ConfigValidator) ClearProgramCache()
ClearProgramCache 清空 Program 缓存 用于测试或需要重新编译所有表达式的场景
func (*ConfigValidator) Evaluate ¶
func (cv *ConfigValidator) Evaluate(key string, exp string) (interface{}, error)
Evaluate 求值函数,返回 (interface{}, error) 返回表达式计算的任何结果
func (*ConfigValidator) GetProgramCacheSize ¶
func (cv *ConfigValidator) GetProgramCacheSize() int
GetProgramCacheSize 获取 Program 缓存大小
type ConfigurationCache ¶
type ConfigurationCache struct {
// contains filtered or unexported fields
}
ConfigurationCache 配置缓存管理器 使用 Map 存储 key -> value 的映射
func NewConfigurationCache ¶
func NewConfigurationCache() *ConfigurationCache
NewConfigurationCache 创建新的配置缓存
func (*ConfigurationCache) Get ¶
func (c *ConfigurationCache) Get(key string) (string, bool)
Get 获取配置值
func (*ConfigurationCache) GetAll ¶
func (c *ConfigurationCache) GetAll() map[string]string
GetAll 获取所有配置
func (*ConfigurationCache) SetAll ¶
func (c *ConfigurationCache) SetAll(configs map[string]string)
SetAll 批量设置配置(用于初始化或刷新)
Click to show internal directories.
Click to hide internal directories.