Documentation
¶
Index ¶
- type Cache
- func (c *Cache[T]) Delete(key string)
- func (c *Cache[T]) Free()
- func (c *Cache[T]) Get(key string) (T, bool)
- func (c *Cache[T]) GetOrSet(key string, value T) (oldValue T, isLoad bool)
- func (c *Cache[T]) GetOrSetFunc(key string, setFn func() (value T, canSet bool)) (oldValue T, isLoad bool)
- func (c *Cache[T]) Set(key string, value T)
- func (c *Cache[T]) Swap(key string, value T) (oldValue T, isLoad bool)
- type CacheStroage
- type JsonByteData
- type LruCache
- type RedisCache
- type RedisConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache[T any] struct { // contains filtered or unexported fields }
func NewCache ¶
func NewCache(memcache CacheStroage[any], remotecache ...CacheStroage[any]) *Cache[any]
默认创any类型的存储
func NewCacheWithType ¶
func NewCacheWithType[T any](memcache CacheStroage[T], remotecache ...CacheStroage[T]) *Cache[T]
带有类型的存储
type CacheStroage ¶
type JsonByteData ¶
type JsonByteData[T any] struct { Data T `json:"Data"` }
type LruCache ¶
type LruCache[T any] struct { // contains filtered or unexported fields }
func NewMemLruCacheStroage ¶
type RedisCache ¶
type RedisCache[T any] struct { // contains filtered or unexported fields }
func NewRedisCacheStroage ¶
func NewRedisCacheStroage(config *RedisConfig, timeout ...int) *RedisCache[any]
Redis存储 传入连接参数和缓存超时时间
func NewRedisCacheStroageWithType ¶
func NewRedisCacheStroageWithType[T any](config *redis.Options, timeout ...int) *RedisCache[T]
Redis存储 传入连接参数和缓存超时时间
type RedisConfig ¶
Click to show internal directories.
Click to hide internal directories.