Documentation ¶
Index ¶
- Variables
- type Config
- type TinyLFU
- func (c *TinyLFU) Apply(cnf *conf.Configuration) error
- func (c *TinyLFU) Clean()
- func (c *TinyLFU) Del(_ context.Context, key string) error
- func (c *TinyLFU) Get(ctx context.Context, key string, value any, opts ...cache.Option) (err error)
- func (c *TinyLFU) GetInner(_ context.Context, key string, value any, raw bool) error
- func (c *TinyLFU) Has(_ context.Context, key string) bool
- func (c *TinyLFU) IsNotFound(err error) bool
- func (c *TinyLFU) Register() error
- func (c *TinyLFU) Set(ctx context.Context, key string, value any, opts ...cache.Option) error
- func (c *TinyLFU) SetInner(_ context.Context, key string, value any, ttl time.Duration, ...) error
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrValueReceiverNil = errors.New("cache: value receiver must not nil pointer")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.4.0
type Config struct { // DriverName set it to register to cache manager. DriverName string `yaml:"driverName" json:"driverName"` Size int `yaml:"size" json:"size"` Samples int `yaml:"samples" json:"samples"` // TTL is default to set item ttl, if you use no expired cache, this value is not used. TTL time.Duration `yaml:"ttl" json:"ttl"` Deviation int64 `yaml:"deviation" json:"deviation"` // Subsidiary indicate whether the cache is a subsidiary cache, // if true, the cache will not be registered to cache manager and ttl will be the max ttl. Subsidiary bool `yaml:"subsidiary" json:"subsidiary"` }
Config is the configuration for TinyLFU cache
type TinyLFU ¶
type TinyLFU struct { Config // contains filtered or unexported fields }
TinyLFU is a cache implementation of TinyLFU algorithm. It forces the cache data to have an expiration time.
Default ttl is 1 minute.Notice that the ttl will be less the setting, randomly reduced by a value between 0 and the offset.
func NewTinyLFU ¶
func NewTinyLFU(cnf *conf.Configuration) (*TinyLFU, error)
func (*TinyLFU) Apply ¶
func (c *TinyLFU) Apply(cnf *conf.Configuration) error
Apply implements the conf.Configurable interface
func (*TinyLFU) Get ¶
Get returns the value for the given key, or ErrCacheMiss. If the value is nil, the value will not be set
func (*TinyLFU) IsNotFound ¶
Click to show internal directories.
Click to hide internal directories.