harbor/src/vendor/github.com/beego/beego/v2/client/cache
Wang Yan 18a3373725
bump beego (#17801)
* bump beego

upgrade beego version from v1.10.12 to v2.0.5

1, beego v2 vserver/web refactor
2, beego v2 context refactor
3, beego v2 session refactor
4, beego v2 cache refactor
5, beego v2 orm refactor

Signed-off-by: MinerYang <yminer@vmware.com>
2022-11-24 18:07:42 +08:00
..
redis bump beego (#17801) 2022-11-24 18:07:42 +08:00
README.md bump beego (#17801) 2022-11-24 18:07:42 +08:00
cache.go bump beego (#17801) 2022-11-24 18:07:42 +08:00
calc_utils.go bump beego (#17801) 2022-11-24 18:07:42 +08:00
conv.go bump beego (#17801) 2022-11-24 18:07:42 +08:00
error_code.go bump beego (#17801) 2022-11-24 18:07:42 +08:00
file.go bump beego (#17801) 2022-11-24 18:07:42 +08:00
memory.go bump beego (#17801) 2022-11-24 18:07:42 +08:00
module.go bump beego (#17801) 2022-11-24 18:07:42 +08:00
random_expired_cache.go bump beego (#17801) 2022-11-24 18:07:42 +08:00

README.md

cache

cache is a Go cache manager. It can use many cache adapters. The repo is inspired by database/sql .

How to install?

go get github.com/beego/beego/v2/client/cache

What adapters are supported?

As of now this cache support memory, Memcache and Redis.

How to use it?

First you must import it

import (
	"github.com/beego/beego/v2/client/cache"
)

Then init a Cache (example with memory adapter)

bm, err := cache.NewCache("memory", `{"interval":60}`)	

Use it like this:

bm.Put("astaxie", 1, 10 * time.Second)
bm.Get("astaxie")
bm.IsExist("astaxie")
bm.Delete("astaxie")

Memory adapter

Configure memory adapter like this:

{"interval":60}

interval means the gc time. The cache will check at each time interval, whether item has expired.

Memcache adapter

Memcache adapter use the gomemcache client.

Configure like this:

{"conn":"127.0.0.1:11211"}

Redis adapter

Redis adapter use the redigo client.

Configure like this:

{"conn":":6039"}