mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 08:00:57 +00:00
Some updates to cache README
This commit is contained in:
parent
b886ed59a5
commit
b68a37a115
49
cache/README.md
vendored
49
cache/README.md
vendored
@ -1,52 +1,59 @@
|
|||||||
## cache
|
## cache
|
||||||
cache is a golang cache manager. It can use cache for many adapters. The repo is inspired by `database/sql` .
|
cache is a Go cache manager. It can use many cache adapters. The repo is inspired by `database/sql` .
|
||||||
|
|
||||||
##How to install
|
|
||||||
|
## How to install?
|
||||||
|
|
||||||
go get github.com/astaxie/beego/cache
|
go get github.com/astaxie/beego/cache
|
||||||
|
|
||||||
|
|
||||||
##how many adapter support
|
|
||||||
|
|
||||||
Now this cache support memory/redis/memcache
|
## What adapters are supported?
|
||||||
|
|
||||||
## how to use it
|
|
||||||
first you must import it
|
|
||||||
|
|
||||||
|
As of now this cache support memory, Memcache and Redis.
|
||||||
|
|
||||||
|
|
||||||
|
## How to use it?
|
||||||
|
|
||||||
|
First you must import it
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/astaxie/beego/cache"
|
"github.com/astaxie/beego/cache"
|
||||||
)
|
)
|
||||||
|
|
||||||
then init an Cache(memory adapter)
|
Then init a Cache (example with memory adapter)
|
||||||
|
|
||||||
bm, err := NewCache("memory", `{"interval":60}`)
|
bm, err := NewCache("memory", `{"interval":60}`)
|
||||||
|
|
||||||
use it like this:
|
Use it like this:
|
||||||
|
|
||||||
bm.Put("astaxie", 1, 10)
|
bm.Put("astaxie", 1, 10)
|
||||||
bm.Get("astaxie")
|
bm.Get("astaxie")
|
||||||
bm.IsExist("astaxie")
|
bm.IsExist("astaxie")
|
||||||
bm.Delete("astaxie")
|
bm.Delete("astaxie")
|
||||||
|
|
||||||
## memory adapter
|
|
||||||
memory adapter config like this:
|
## Memory adapter
|
||||||
|
|
||||||
|
Configure memory adapter like this:
|
||||||
|
|
||||||
{"interval":60}
|
{"interval":60}
|
||||||
|
|
||||||
interval means the gc time. The cache will every interval time to check wheather have item expired.
|
interval means the gc time. The cache will check at each time interval, whether item has expired.
|
||||||
|
|
||||||
## memcache adapter
|
|
||||||
memory adapter use the vitess's [memcache](code.google.com/p/vitess/go/memcache) client.
|
|
||||||
|
|
||||||
the config like this:
|
## Memcache adapter
|
||||||
|
|
||||||
|
memory adapter use the vitess's [Memcache](http://code.google.com/p/vitess/go/memcache) client.
|
||||||
|
|
||||||
|
Configure like this:
|
||||||
|
|
||||||
{"conn":"127.0.0.1:11211"}
|
{"conn":"127.0.0.1:11211"}
|
||||||
|
|
||||||
|
|
||||||
## redis adapter
|
## Redis adapter
|
||||||
redis adapter use the [redigo](github.com/garyburd/redigo/redis) client.
|
|
||||||
|
|
||||||
the config like this:
|
Redis adapter use the [redigo](http://github.com/garyburd/redigo/redis) client.
|
||||||
|
|
||||||
{"conn":":6039"}
|
Configure like this:
|
||||||
|
|
||||||
|
{"conn":":6039"}
|
||||||
|
Loading…
Reference in New Issue
Block a user