cache

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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 启动缓存刷新服务

func (*CacheRefreshService) Stop

func (s *CacheRefreshService) Stop()

Stop 停止缓存刷新服务

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 缓存大小

func (*ConfigValidator) Validate

func (cv *ConfigValidator) Validate(key string, exp string) (bool, error)

Validate 验证函数,返回 (bool, error) 在运行时检查结果是否为 bool

type ConfigurationCache

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

ConfigurationCache 配置缓存管理器 使用 Map 存储 key -> value 的映射

func NewConfigurationCache

func NewConfigurationCache() *ConfigurationCache

NewConfigurationCache 创建新的配置缓存

func (*ConfigurationCache) Clear

func (c *ConfigurationCache) Clear()

Clear 清空所有缓存

func (*ConfigurationCache) Delete

func (c *ConfigurationCache) Delete(key string)

Delete 删除配置

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) Set

func (c *ConfigurationCache) Set(key, value string)

Set 设置配置值

func (*ConfigurationCache) SetAll

func (c *ConfigurationCache) SetAll(configs map[string]string)

SetAll 批量设置配置(用于初始化或刷新)

func (*ConfigurationCache) Size

func (c *ConfigurationCache) Size() int

Size 获取缓存大小

Jump to

Keyboard shortcuts

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