Documentation
¶
Index ¶
- type DataWithSignal
- type DistributedTTLru
- func (c *DistributedTTLru[T]) Get(key string) (t T, exist bool)
- func (c *DistributedTTLru[T]) Set(key string, v T, ttl time.Duration, signals []string)
- func (c *DistributedTTLru[T]) Size() (curr, max int)
- func (c *DistributedTTLru[T]) Start(ctx context.Context) (err error)
- func (c *DistributedTTLru[T]) UpdateSignal(signals ...string) error
- type TTLru
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataWithSignal ¶ added in v0.0.7
type DistributedTTLru ¶ added in v0.0.7
type DistributedTTLru[T any] struct { // contains filtered or unexported fields }
func NewDistributedTTLru ¶ added in v0.0.7
NewDistributedTTLru 创建一个可以被分布式清理的 TTLru size: 做多缓存多少个条目 scope: redis scope redis: redis 客户端 一定要记得调用 Start,否则数据不会被清理。
func (*DistributedTTLru[T]) Get ¶ added in v0.0.7
func (c *DistributedTTLru[T]) Get(key string) (t T, exist bool)
func (*DistributedTTLru[T]) Set ¶ added in v0.0.7
func (c *DistributedTTLru[T]) Set(key string, v T, ttl time.Duration, signals []string)
Set 当 signals 改变时缓存也会被清空。
func (*DistributedTTLru[T]) Size ¶ added in v0.0.7
func (c *DistributedTTLru[T]) Size() (curr, max int)
Size 返回 lru 大小
func (*DistributedTTLru[T]) Start ¶ added in v0.0.7
func (c *DistributedTTLru[T]) Start(ctx context.Context) (err error)
Start 开始监听清理事件,一定记得 Start,否则数据不会被清理。
func (*DistributedTTLru[T]) UpdateSignal ¶ added in v0.0.7
func (c *DistributedTTLru[T]) UpdateSignal(signals ...string) error
UpdateSignal 发送清空信号,清空包含 signal 的数据
Click to show internal directories.
Click to hide internal directories.