caches

package
v0.66.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 9 Imported by: 0

README

caches

当前包在 github action 上只能跑在 linux 系统,作为独立的包,不影响其它包在所有系统上运行。

Documentation

Overview

Package caches 内置的缓存接口实现

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal added in v0.65.0

func Marshal(v any) ([]byte, error)

Marshal 序列化对象

这是 cache.Cache 存储对象时的转换方法, 除了判断 cache.Serializer 之外,还提供了默认的 gob 编码方式。

大部分时候 cache.Driver 的实现者直接调用此方法即可, 如果需要自己实现,需要注意 cache.Serializer 接口的判断。

func NewMemcache

func NewMemcache(addr ...string) cache.Driver

NewFromServers 声明一个新的 Memcache 实例

func NewMemory

func NewMemory(gc time.Duration) cache.Driver

NewMemory 声明一个内存缓存

size 表示初始时的记录数量; gc 表示执行回收操作的间隔。

func NewRedis

func NewRedis(url string, o ...redis.DialOption) (cache.Driver, error)

NewRedis 返回 redis 的缓存实现

func Unmarshal added in v0.65.0

func Unmarshal(bs []byte, v any) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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