cache

package
v0.11.15 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache[K comparable, V any] struct {
	Storage[K, V]
}

func (*Cache[K, V]) GetAndSetCacheData

func (c *Cache[K, V]) GetAndSetCacheData(key string, id K, fn func() (V, error)) (value V, err error)

GetAndSetCacheData 获取缓存后数据

func (*Cache[K, V]) GetAndSetCacheMap

func (c *Cache[K, V]) GetAndSetCacheMap(key string, ids []K, fn func([]K) (map[K]V, error)) (v map[K]V, err error)

GetAndSetCacheMap 获取缓存后数据 map形式

func (*Cache[K, V]) GetCacheMap

func (c *Cache[K, V]) GetCacheMap(key string, ids []K) (v map[K]V)

GetCacheMap 获取缓存数据 map形式

func (*Cache[K, V]) GetCacheValue

func (c *Cache[K, V]) GetCacheValue(key string, id K) (value V)

GetCacheValue 获取缓存数据

func (*Cache[K, V]) SetCacheMap

func (c *Cache[K, V]) SetCacheMap(key string, ids []K, fn func([]K) (map[K]V, error)) (err error)

SetCacheMap 设置缓存数据 map形式

func (*Cache[K, V]) SetCacheValue

func (c *Cache[K, V]) SetCacheValue(key string, id K, fn func() (V, error)) (err error)

SetCacheValue 设置缓存数据

type Storage

type Storage[K comparable, V any] interface {
	GetCacheMapOrigin(key string, ids []K) (v map[K]V, idsNone []K)
	SetCacheMapOrigin(key string, idsNone []K, fn func([]K) (map[K]V, error), v map[K]V) (err error)
}

Storage 接入本地缓存库需要实现的接口

Directories

Path Synopsis
v2

Jump to

Keyboard shortcuts

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