cache

package
v0.21.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2019 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package cache provides a simple key-value cache store, supporting just a handful of caching operations. Note, if not explicitly set, a default cache client will be created; this cache client will be used for all usage of this package in a given application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacherInit added in v0.20.0

func CacherInit(init func() Cacher)

CacherInit sets the Cacher to be used for all cache operations. If an init func is supplied, it will be used for setup; otherwise, the default Cacher will be used. The supplied init function must accept a Cacher as its argument, so that `client` may be set.

func Del added in v0.8.0

func Del(keys ...string) error

Del removes data at the given key(s)

func Get

func Get(key string) ([]byte, error)

Get returns the data stored under the given key.

func Set

func Set(key string, data []byte, expiration time.Duration) error

Set stores data for a set period of time at the given key.

Types

type Cacher added in v0.20.0

type Cacher interface {
	Del(...string) error
	Get(string) ([]byte, error)
	Set(string, interface{}, time.Duration) error
}

Cacher defines the methods of any cache client.

Directories

Path Synopsis
Package redis provides a wrapper around github.com/go-redis/redis, specifically to satisfy the cache.Cacher interface.
Package redis provides a wrapper around github.com/go-redis/redis, specifically to satisfy the cache.Cacher interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL