Documentation
¶
Index ¶
- Variables
- type Cache
- func (c *Cache) Close()
- func (c *Cache) Delete(key string) error
- func (c *Cache) Get(key string) ([]byte, error)
- func (c *Cache) GetString(key string) (string, error)
- func (c *Cache) GetValue(key string, value interface{}) error
- func (c *Cache) Has(key string) bool
- func (c *Cache) Set(key string, value []byte) error
- func (c *Cache) SetEX(key string, value []byte, expiration time.Duration) error
- func (c *Cache) SetEXString(key, value string, expiration time.Duration) error
- func (c *Cache) SetString(key, value string) error
- func (c *Cache) SetValue(key string, value interface{}) error
- type Option
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func NewCache ¶
NewCache 返回一个新的 Cache 实例。 它使用提供的配置选项初始化一个新的 BigCache 实例。 缓存将根据提供的分钟参数具有默认的生命周期。 如果指定了任何选项,将应用于缓存配置。
func (*Cache) Close ¶ added in v0.0.2
func (c *Cache) Close()
Close 关闭缓存并释放与之相关的任何资源。 当缓存不再需要时,应调用此方法以确保正确清理。
func (*Cache) SetEX ¶ added in v0.1.0
SetEX 使用过期时间在缓存中设置一个值。 值将在指定的持续时间后从缓存中删除。 如果键为空或在设置操作中出现任何问题,则返回错误。
func (*Cache) SetEXString ¶ added in v0.1.0
SetEXString 使用过期时间在缓存中设置一个字符串值。 这是一个便捷方法,先将字符串转换为字节切片,然后调用 SetEX。
type Option ¶ added in v0.0.3
func WithCleanWindow ¶ added in v0.0.3
WithCleanWindow 设置缓存的清理频率。 在此时间段内,过期的条目将从缓存中删除。 这有助于保持最佳性能和内存使用,确保过期条目不会滞留在缓存中。
func WithContext ¶ added in v0.0.3
WithContext 允许为 BigCache 实例设置自定义上下文。 该上下文可用于控制缓存的生命周期,允许进行取消和超时管理。
func WithLifeWindow ¶ added in v0.0.3
WithLifeWindow 设置缓存中条目的有效期。 超过此时间后,条目将自动从缓存中删除。 这有助于管理内存使用,并确保不会提供过时的数据。
Click to show internal directories.
Click to hide internal directories.