gocache

package
v0.0.0-...-270bddf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config any) (driver.Driver, error)

Types

type GoCacheConfig

type GoCacheConfig struct {
	DefaultExpiration time.Duration
	CleanupInterval   time.Duration
}

type GoCacheDriver

type GoCacheDriver struct {
	// contains filtered or unexported fields
}

func (*GoCacheDriver) Add

func (g *GoCacheDriver) Add(k string, v any, d time.Duration) error

Add 仅当给定键的项目尚不存在或现有项目已过期时,才将项目添加到缓存。否则返回错误。

func (*GoCacheDriver) DecrementInt

func (g *GoCacheDriver) DecrementInt(k string, n int) (int, error)

func (*GoCacheDriver) DecrementInt64

func (g *GoCacheDriver) DecrementInt64(k string, n int64) (int64, error)

func (*GoCacheDriver) DecrementUint

func (g *GoCacheDriver) DecrementUint(k string, n uint) (uint, error)

func (*GoCacheDriver) DecrementUint64

func (g *GoCacheDriver) DecrementUint64(k string, n uint64) (uint64, error)

func (*GoCacheDriver) Delete

func (g *GoCacheDriver) Delete(k string)

Delete 从缓存中删除一个项目。如果密钥不在缓存中,则不执行任何操作。

func (*GoCacheDriver) DeleteExpired

func (g *GoCacheDriver) DeleteExpired()

DeleteExpired 删除过期的缓存

func (*GoCacheDriver) Flush

func (g *GoCacheDriver) Flush()

Flush 清空缓存

func (*GoCacheDriver) Get

func (g *GoCacheDriver) Get(k string) (any, bool)

Get 从缓存中获取一个项目。返回该项或 nil,以及一个指示是否找到该键的布尔值。

func (*GoCacheDriver) GetWithExpiration

func (g *GoCacheDriver) GetWithExpiration(k string) (any, time.Time, bool)

GetWithExpiration 从缓存中返回一个项目及其过期时间。它返回该项目或 nil、过期时间(如果已设置) (如果该项目永不过期,则返回时间的零值。Time 返回) 以及指示是否找到该键的 bool。

func (*GoCacheDriver) IncrementInt

func (g *GoCacheDriver) IncrementInt(k string, n int) (int, error)

func (*GoCacheDriver) IncrementInt64

func (g *GoCacheDriver) IncrementInt64(k string, n int64) (int64, error)

func (*GoCacheDriver) IncrementUint

func (g *GoCacheDriver) IncrementUint(k string, n uint) (uint, error)

func (*GoCacheDriver) IncrementUint64

func (g *GoCacheDriver) IncrementUint64(k string, n uint64) (uint64, error)

func (*GoCacheDriver) Replace

func (g *GoCacheDriver) Replace(k string, x any, d time.Duration) error

Replace 替换缓存,如果缓存不存在,则返回错误

func (*GoCacheDriver) Set

func (g *GoCacheDriver) Set(k string, x any, d time.Duration)

Set 添加/替换现有的缓存设置,包括过期时间,如果过期时间是0,则使用默认过期时间,如果为-1则表示永不过期

func (*GoCacheDriver) SetDefault

func (g *GoCacheDriver) SetDefault(k string, x any)

SetDefault 添加/替换现有的缓存设置,使用默认过期时间

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL