Documentation
¶
Index ¶
- Variables
- type Entry
- type LimitedCache
- func (lc *LimitedCache) AdjustTTLs(ttlFunc func(string) time.Duration)
- func (lc *LimitedCache) Close()
- func (lc *LimitedCache) Delete(ctx context.Context, key string)
- func (lc *LimitedCache) Flush(ctx context.Context)
- func (lc *LimitedCache) Get(ctx context.Context, key string) (any, bool)
- func (lc *LimitedCache) GetMetrics() Metrics
- func (lc *LimitedCache) GetMulti(ctx context.Context, keys []string) map[string]any
- func (lc *LimitedCache) ItemCount() int
- func (lc *LimitedCache) Set(ctx context.Context, key string, value any, ttl ...time.Duration) error
- func (lc *LimitedCache) SetDefaultTTL(ttl time.Duration)
- func (lc *LimitedCache) SetEvictionCallback(callback func(key string, value any))
- func (lc *LimitedCache) SetMulti(ctx context.Context, items map[string]any, ttl ...time.Duration) error
- type Metrics
- type MultiLevelCache
- func (c *MultiLevelCache) Clear(ctx context.Context) error
- func (c *MultiLevelCache) Close() error
- func (c *MultiLevelCache) Delete(ctx context.Context, key string) error
- func (c *MultiLevelCache) Exists(ctx context.Context, key string) (bool, error)
- func (c *MultiLevelCache) Get(ctx context.Context, key string, value any) (bool, error)
- func (c *MultiLevelCache) GetMulti(ctx context.Context, keys []string) (map[string]any, error)
- func (c *MultiLevelCache) GetTTL(ctx context.Context, key string) (time.Duration, error)
- func (c *MultiLevelCache) Incr(ctx context.Context, key string) (int64, error)
- func (c *MultiLevelCache) Set(ctx context.Context, key string, value any, ttl ...time.Duration) error
- func (c *MultiLevelCache) SetMulti(ctx context.Context, items map[string]any, ttl ...time.Duration) error
- func (c *MultiLevelCache) SetNX(ctx context.Context, key string, value any, ttl ...time.Duration) (bool, error)
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type LimitedCache ¶
type LimitedCache struct {
// contains filtered or unexported fields
}
LimitedCache implements a size-limited cache
func NewLimitedCache ¶
func NewLimitedCache(maxSize int64, numSegments int, defaultTTL time.Duration) (*LimitedCache, error)
NewLimitedCache creates a new instance of LimitedCache
func (*LimitedCache) AdjustTTLs ¶ added in v1.0.3
func (lc *LimitedCache) AdjustTTLs(ttlFunc func(string) time.Duration)
func (*LimitedCache) Close ¶ added in v1.0.3
func (lc *LimitedCache) Close()
func (*LimitedCache) Flush ¶
func (lc *LimitedCache) Flush(ctx context.Context)
func (*LimitedCache) GetMetrics ¶ added in v1.0.1
func (lc *LimitedCache) GetMetrics() Metrics
func (*LimitedCache) ItemCount ¶
func (lc *LimitedCache) ItemCount() int
func (*LimitedCache) SetDefaultTTL ¶ added in v1.0.1
func (lc *LimitedCache) SetDefaultTTL(ttl time.Duration)
func (*LimitedCache) SetEvictionCallback ¶ added in v1.0.1
func (lc *LimitedCache) SetEvictionCallback(callback func(key string, value any))
SetEvictionCallback 設置驅逐回調函數 SetEvictionCallback sets the eviction callback function
type Metrics ¶ added in v1.0.1
type Metrics struct { Hits *atomic.Int64 Misses *atomic.Int64 Evictions *atomic.Int64 Size *atomic.Int64 }
Metrics stores cache statistics
type MultiLevelCache ¶
type MultiLevelCache struct { EncoderFunc func(w io.Writer) serialization.Encoder DecoderFunc func(r io.Reader) serialization.Decoder // contains filtered or unexported fields }
MultiLevelCache 實現多層緩存系統
func NewMultiLevelCache ¶
func NewMultiLevelCache(mlcConfig config.MLCConfig, client *redis.Client) (*MultiLevelCache, error)
NewMultiLevelCache 創建一個新的 MultiLevelCache 實例
func (*MultiLevelCache) Close ¶
func (c *MultiLevelCache) Close() error
func (*MultiLevelCache) Delete ¶
func (c *MultiLevelCache) Delete(ctx context.Context, key string) error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.