# README
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"}
# Packages
Package memcache for cache provider
depend on github.com/bradfitz/gomemcache/memcache
go install github.com/bradfitz/gomemcache/memcache
Usage: import( _ "github.com/beego/beego/v2/client/cache/memcache" "github.com/beego/beego/v2/client/cache" )
bm, err := cache.NewCache("memcache", `{"conn":"127.0.0.1:11211"}`)
more docs http://beego.me/docs/module/cache.md.
Package redis for cache provider
depend on github.com/gomodule/redigo/redis
go install github.com/gomodule/redigo/redis
Usage: import( _ "github.com/beego/beego/v2/client/cache/redis" "github.com/beego/beego/v2/client/cache" )
bm, err := cache.NewCache("redis", `{"conn":"127.0.0.1:11211"}`)
more docs http://beego.me/docs/module/cache.md.
No description provided by the author
# Functions
FileGetContents Reads bytes from a file.
FilePutContents puts bytes into a file.
GetBool converts interface to bool.
GetFloat64 converts interface to float64.
GetInt converts interface to int.
GetInt64 converts interface to int64.
GetString converts interface to string.
GobDecode Gob decodes a file cache item.
GobEncode Gob encodes a file cache item.
NewCache creates a new cache driver by adapter name and config string.
NewFileCache creates a new file cache with no config.
NewMemoryCache returns a new MemoryCache.
Register makes a cache adapter available by the adapter name.
# Variables
No description provided by the author
No description provided by the author
1 minute.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
cache file deep level if auto generated cache files.
cache expire time, default is no expire forever.
cache file suffix.
cache directory.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
FileCache is cache adapter for file storage.
FileCacheItem is basic unit of file cache adapter which contains data and expire time.
MemoryCache is a memory cache adapter.
MemoryItem stores memory cache item.
# Interfaces
Cache interface contains all behaviors for cache adapter.
# Type aliases
Instance is a function create a new Cache Instance.