cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package cache is a caching and cache-filling library

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithContext

func WithContext(ctx context.Context, c Cache) context.Context

WithContext returns a copy of parent in which the `Cache` is stored

Types

type Cache

type Cache interface {
	// NewGroup creates a LRU caching namespace with a size limit and a load
	// function to be called when the value is mising
	NewGroup(name string, cacheBytes int64, loader LoadFunc) Group
}

func FromContext

func FromContext(ctx contextutil.ValueContext) Cache

FromContext returns a `Cache` instance associated with `ctx`, or a `NopCache` if no `Cache` instance could be found.

func NopCache

func NopCache() Cache

NopCache returns a new cache instance which does not cache anything

type Dependencies

type Dependencies interface {
	Disco() disco.Agent
}

Dependencies is an interface to "inject" required services

type Group

type Group interface {
	Get(ctx context.Context, key string) ([]byte, error)
}

A Group is a cache namespace

func NewGroup

func NewGroup(ctx context.Context, name string, cacheBytes int64, loader LoadFunc) Group

NewGroup calls `NewGroup` on the context `Cache`

type LoadFunc

type LoadFunc func(context context.Context, key string) ([]byte, error)

A LoadFunc loads data for a key.

Directories

Path Synopsis
local
Package local provides an LRU cache and cache-filling library that only runs on the local instance.
Package local provides an LRU cache and cache-filling library that only runs on the local instance.
Package lru implements a LRU cache.
Package lru implements a LRU cache.

Jump to

Keyboard shortcuts

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