cache

package
v0.13.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Store data into the cache.
	//
	// Note that individual byte buffers may be retained by the cache!
	Store(ctx context.Context, data map[string][]byte, ttl time.Duration)

	// Fetch multiple keys from cache. Returns map of input keys to data.
	// If key isn't in the map, data for given key was not found.
	Fetch(ctx context.Context, keys []string) map[string][]byte
}

Generic best-effort cache.

type MemcachedCache

type MemcachedCache struct {
	// contains filtered or unexported fields
}

MemcachedCache is a memcached-based cache.

func NewMemcachedCache

func NewMemcachedCache(name string, logger log.Logger, memcached cacheutil.MemcachedClient, reg prometheus.Registerer) *MemcachedCache

NewMemcachedCache makes a new MemcachedCache.

func (*MemcachedCache) Fetch

func (c *MemcachedCache) Fetch(ctx context.Context, keys []string) map[string][]byte

Fetch fetches multiple keys and returns a map containing cache hits, along with a list of missing keys. In case of error, it logs and return an empty cache hits map.

func (*MemcachedCache) Store

func (c *MemcachedCache) Store(ctx context.Context, data map[string][]byte, ttl time.Duration)

Store data identified by keys. The function enqueues the request and returns immediately: the entry will be asynchronously stored in the cache.

Jump to

Keyboard shortcuts

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