Documentation ¶
Overview ¶
Package cachego provides a simple way to use cache drivers.
Example Usage ¶
The following is a simple example using memcached driver:
import ( "fmt" "github.com/faabiosr/cachego" "github.com/bradfitz/gomemcache/memcache" ) func main() { cache := cachego.NewMemcached( memcached.New("localhost:11211"), ) cache.Save("foo", "bar") fmt.Println(cache.Fetch("foo")) }
Index ¶
Constants ¶
View Source
const ( // ErrCacheExpired returns an error when the cache key was expired. ErrCacheExpired = err("cache expired") // ErrFlush returns an error when flush fails. ErrFlush = err("unable to flush") // ErrSave returns an error when save fails. ErrSave = err("unable to save") // ErrDelete returns an error when deletion fails. ErrDelete = err("unable to delete") // ErrDecode returns an errors when decode fails. ErrDecode = err("unable to decode") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Contains check if a cached key exists Contains(key string) bool // Delete remove the cached key Delete(key string) error // Fetch retrieve the cached key value Fetch(key string) (string, error) // FetchMulti retrieve multiple cached keys value FetchMulti(keys []string) map[string]string // Flush remove all cached keys Flush() error // Save cache a value by key Save(key string, value string, lifeTime time.Duration) error }
Cache is the top-level cache interface
Directories ¶
Path | Synopsis |
---|---|
Package bolt providers a cache driver that stores the cache using BoltDB.
|
Package bolt providers a cache driver that stores the cache using BoltDB. |
Package chain provides chaining cache drivers operations, in case of failure the driver try to apply using the next driver informed, until fail.
|
Package chain provides chaining cache drivers operations, in case of failure the driver try to apply using the next driver informed, until fail. |
Package file providers a cache driver that stores the cache content in files.
|
Package file providers a cache driver that stores the cache content in files. |
Package memcached providers a cache driver that stores the cache in Memcached.
|
Package memcached providers a cache driver that stores the cache in Memcached. |
Package mongo providers a cache driver that stores the cache in MongoDB.
|
Package mongo providers a cache driver that stores the cache in MongoDB. |
Package redis providers a cache driver that stores the cache in Redis.
|
Package redis providers a cache driver that stores the cache in Redis. |
Package sqlite3 providers a cache driver that stores the cache in SQLite3.
|
Package sqlite3 providers a cache driver that stores the cache in SQLite3. |
Package sync providers a cache driver that uses standard golang sync.Map.
|
Package sync providers a cache driver that uses standard golang sync.Map. |
Click to show internal directories.
Click to hide internal directories.