cache

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CacheStoreRistretto TODO
	// There is a bug for CacheStoreRistretto, do not use it.
	// Use CacheStoreGoCache or CacheStoreRedis or both.
	CacheStoreRistretto = "ristretto"
	CacheStoreGoCache   = "go-cache"
	CacheStoreRedis     = "redis"
)

Variables

Functions

func NewCacheManager added in v2.2.0

func NewCacheManager(conf config.Config) gocache.CacheInterface[any]

Types

type ARCCache

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

func NewARCCache

func NewARCCache(size int, ttl time.Duration) *ARCCache

func (ARCCache) Del

func (l ARCCache) Del(key string)

func (ARCCache) Get

func (l ARCCache) Get(key string) ([]byte, bool)

func (ARCCache) Set

func (l ARCCache) Set(key string, data []byte)

type IStore

type IStore interface {
	Get(key interface{}) (value interface{}, ok bool)
	Add(key, value interface{})
	Remove(key interface{})
}

type Item

type Item struct {
	Key      string
	Value    interface{}
	ExpireAt time.Time
}

type LruCache

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

func NewLruCache

func NewLruCache(size int, ttl time.Duration) *LruCache

func (LruCache) Del

func (l LruCache) Del(key string)

func (LruCache) Get

func (l LruCache) Get(key string) ([]byte, bool)

func (LruCache) Set

func (l LruCache) Set(key string, data []byte)

type LruCacheAdapter

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

func (*LruCacheAdapter) Add

func (l *LruCacheAdapter) Add(key, value interface{})

func (*LruCacheAdapter) Get

func (l *LruCacheAdapter) Get(key interface{}) (value interface{}, ok bool)

func (*LruCacheAdapter) Remove

func (l *LruCacheAdapter) Remove(key interface{})

type TwoQueueCache

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

func NewTwoQueueCache

func NewTwoQueueCache(size int, ttl time.Duration, options ...TwoQueueCacheOption) *TwoQueueCache

func (TwoQueueCache) Del

func (l TwoQueueCache) Del(key string)

func (TwoQueueCache) Get

func (l TwoQueueCache) Get(key string) ([]byte, bool)

func (TwoQueueCache) Set

func (l TwoQueueCache) Set(key string, data []byte)

type TwoQueueCacheOption

type TwoQueueCacheOption func(*TwoQueueCache)

func WithGhostRatio

func WithGhostRatio(ghostRatio float64) TwoQueueCacheOption

func WithRecentRatio

func WithRecentRatio(recentRatio float64) TwoQueueCacheOption

Jump to

Keyboard shortcuts

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