memkv

package
v1.3.90 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrExpired           = errors.New("expired record")
	ErrInvalidRecordType = errors.New("invalid record type")
	ErrNotFound          = gorm.ErrRecordNotFound
)

Functions

func ListWithKeyPrefix

func ListWithKeyPrefix[T cachestore.ConsistentRecord](c *Cache, filterWithKeyPrefix T) ([]T, error)

Types

type Cache

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

Cache 结构,用于内存缓存

func NewCache

func NewCache(pCtx context.Context, client KvDbClientIf, conf CacheConf, records ...any) *Cache

NewCache 创建一个新的缓存实例

func (*Cache) CreateOrUpdate

func (c *Cache) CreateOrUpdate(rt cachestore.Record, expireAfterInSec int64) (exist bool, err error)

func (*Cache) Dump

func (c *Cache) Dump()

func (*Cache) Exist

func (c *Cache) Exist(filter cachestore.Record) (bool, error)

func (*Cache) Get

func (c *Cache) Get(filter cachestore.Record) (cachestore.Record, error)

func (*Cache) Set

func (c *Cache) Set(rt cachestore.Record, expireAfterInSec int64) error

func (*Cache) Update

func (c *Cache) Update(rt cachestore.Record) error

type CacheConf

type CacheConf struct {
	GcInterval int `vx_default:"10"` //in sec
}

type KvDbClientIf

type KvDbClientIf interface {
	Set(records any) error
	Get(filterAndDest any) error
	ListWithKeyPrefix(dest any, filter any, keyFieldName, keyPrefix string) error
	DeleteExpired(filter any) error
}

Jump to

Keyboard shortcuts

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