Documentation ¶
Overview ¶
Package freecache contains an implementation of the `gokv.Store` interface for FreeCache.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = Options{ Size: 256 * 1024 * 1024, Codec: encoding.JSON, }
DefaultOptions is an Options object with default values. Size: 256 MiB, Codec: encoding.JSON
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // The size of the cache in bytes. // 512 KiB is the minimum size // (if you set a lower size, 512 KiB will be used instead). // If you set 0, the default size will be used. // When the size is reached and you store new entries, // old entries are evicted. // Optional (256 MiB by default). Size int // Encoding format. // Optional (encoding.JSON by default). Codec encoding.Codec }
Options are the options for the FreeCache store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a gokv.Store implementation for FreeCache.
func NewStore ¶
NewStore creates a FreeCache store.
You should call the Close() method on the store when you're done working with it.
func (Store) Delete ¶
Delete deletes the stored value for the given key. Deleting a non-existing key-value pair does NOT lead to an error. The key must not be "".
func (Store) Get ¶
Get retrieves the stored value for the given key. You need to pass a pointer to the value, so in case of a struct the automatic unmarshalling can populate the fields of the object that v points to with the values of the retrieved object's values. If no value is found it returns (false, nil). The key must not be "" and the pointer must not be nil.