# 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/astaxie/beego/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/astaxie/beego/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"}
# Functions
将一个数据结构转填充另一个数据结构.
clear all cache.
------------------- Decode 用json进行数据解码
.
decrease cached int value by key, as a counter.
No description provided by the author
No description provided by the author
用json进行数据编码
.
GetBool convert interface to bool.
No description provided by the author
从缓存或DB中取数据 value 传引用.
No description provided by the author
GetFloat64 convert interface to float64.
GetInt convert interface to int.
GetInt64 convert interface to int64.
GetString convert interface to string.
increase cached int value by key, as a counter.
No description provided by the author
No description provided by the author
No description provided by the author
NewCache Create a new cache driver by adapter name and config string.
NewMemoryCache returns a new MemoryCache.
NewRedisCache create new redis cache with default collection name.
发布消息.
发布消息.
Register makes a cache adapter available by the adapter name.
No description provided by the author
设置db缓存.
接受消息.
接受消息.
# Variables
1 minute.
DefaultKey the collection name of redis for cache adapter.
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
MemoryCache is Memory cache adapter.
MemoryItem store memory cache item.
Cache is Redis cache adapter.
# Interfaces
Cache interface contains all behaviors for cache adapter.