Documentation
¶
Overview ¶
Package cachex 提供分片并发缓存基座(TTL、LRU、事件、指标与链路钩子)。 实现主体位于 internal/core,本包仅暴露稳定公开 API。
Index ¶
- Constants
- func GetOrSet(ctx context.Context, c *Cache, key string, ttl time.Duration, ...) (any, error)
- type Cache
- type CacheEvent
- type EventHook
- type EvictReason
- type Metrics
- type Option
- func WithCapacity(n int) Option
- func WithCleanupInterval(d time.Duration) Option
- func WithDefaultTTL(d time.Duration) Option
- func WithEventHook(h EventHook) Option
- func WithLRURefresh(interval int) Option
- func WithMetrics(m Metrics) Option
- func WithOnEvicted(fn func(key string, value any, reason EvictReason)) Option
- func WithShards(n int) Option
- func WithTraceHook(h TraceHook) Option
- type Stats
- type TraceAttr
- type TraceHook
Constants ¶
View Source
const ( EvictCapacity = core.EvictCapacity EvictExpired = core.EvictExpired )
View Source
const CodeInvalidConfig = core.CodeInvalidConfig
View Source
const Version = core.Version
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CacheEvent ¶ added in v1.2.0
type CacheEvent = core.CacheEvent
type EvictReason ¶
type EvictReason = core.EvictReason
type Option ¶
func WithCapacity ¶
func WithCleanupInterval ¶
func WithDefaultTTL ¶
func WithEventHook ¶ added in v1.2.0
func WithLRURefresh ¶ added in v0.2.0
func WithMetrics ¶
func WithOnEvicted ¶
func WithOnEvicted(fn func(key string, value any, reason EvictReason)) Option
func WithShards ¶
func WithTraceHook ¶ added in v1.0.3
Click to show internal directories.
Click to hide internal directories.