Skip to content

Latest commit

 

History

History
40 lines (24 loc) · 1.45 KB

README.md

File metadata and controls

40 lines (24 loc) · 1.45 KB

Cacher

TravisCI GoDoc reference

Cacher is a port of the PHP a library Scrapbook.

It defines an interface to interact with several cache systems without having to worry about the implementation of said cache layer.

Methods

Add(key string, value interface{}, ttl int) bool

Adds a new key to the cache if the key is not already stored. If the key is already stored false will be returned.

Set(key string, value interface{}, ttl int) bool

Sets the value for the specified key, regardless of wether or not the key has already been set. If the key has already been set, it will overwrite the previous value.

Get(key string) interface{}

Gets the value for the given key.

Flush() bool

Resets the cache store and deletes all cached values.

Implementations

MemoryCache

MemoryCache stores all the data in memory. This is a non persistent cache store that will be flushed every time the application that uses the cache is terminates.

This cache is perfect to use for testing. There are no other dependencies required other than enough available memory.