API 参考
缓存配置
缓存模块配置说明。
缓存配置
配置前缀: nebula.data.cache
本地缓存配置
nebula:
data:
cache:
enabled: true
type: local # 缓存类型: local, redis, multi-level
default-ttl: 1h # 默认过期时间
local:
enabled: true
max-size: 10000 # 最大缓存条目
initial-capacity: 1000 # 初始容量
expire-after-write: 30m # 写入后过期时间
expire-after-access: 1h # 访问后过期时间
cleanup-interval: 5m # 清理间隔
eviction-policy: LRU # 驱逐策略: LRU, LFU, FIFO
stats-enabled: true # 是否启用统计
Redis 缓存配置
nebula:
data:
cache:
enabled: true
type: redis
default-ttl: 1h
redis:
enabled: true
host: localhost
port: 6379
password: your-password
database: 0
timeout: 2s
key-prefix: "myapp:cache:"
serialization: JSON # 序列化类型: JSON, JDK, KRYO
pool:
max-active: 8 # 最大活跃连接
max-idle: 8 # 最大空闲连接
min-idle: 0 # 最小空闲连接
max-wait: -1ms # 最大等待时间
connect-timeout: 2s # 连接超时
多级缓存配置
nebula:
data:
cache:
enabled: true
type: multi-level
default-ttl: 1h
multi-level:
enabled: true
local-cache-enabled: true # 启用L1本地缓存
remote-cache-enabled: true # 启用L2远程缓存
sync-on-update: true # 更新时同步
l1-write-back-enabled: true # L1回写启用
l1-default-ttl: 10m # L1默认TTL
l1-write-back-ttl: 5m # L1回写TTL
l1-ttl-ratio: 0.5 # L1 TTL比例
l1-max-size: 10000 # L1最大条目数