cache

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2020 License: MIT Imports: 6 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 Del added in v0.8.0

func Del(ctx context.Context, keys ...string) error

Del removes data at the given key(s).

func Get

func Get(ctx context.Context, key string) ([]byte, error)

Get returns the data stored under the given key.

func Init added in v0.23.0

func Init(init func() Cacher)

Init 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 return a Cacher, so that `client` may be set.

func Set

func Set(ctx context.Context, key string, data interface{}, 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(context.Context, ...string) error
	Get(context.Context, string) ([]byte, error)
	Set(context.Context, string, interface{}, time.Duration) error
}

Cacher defines the methods of any cache client.

func Default added in v0.23.0

func Default() Cacher

Default returns the default Cacher.

Directories

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

Jump to

Keyboard shortcuts

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