cache

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound means that the key was not found.
	ErrNotFound = errors.New("key not found")
)

Functions

This section is empty.

Types

type InMemory

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

InMemory is an implementation of the cache interface which stores values in-memory.

func NewInMemory

func NewInMemory() *InMemory

NewInMemory creates a new InMemory instance with default values.

func (*InMemory) Get

func (c *InMemory) Get(key string) (interface{}, error)

Get retrieves a value from the InMemory cache implementation.

func (*InMemory) Set

func (c *InMemory) Set(key string, value interface{}) error

Set sets a value for a key in the InMemory cache implementation.

func (*InMemory) WithExpiration

func (c *InMemory) WithExpiration(d time.Duration) *InMemory

WithExpiration updates the expiration value of `c`.

type Interface

type Interface interface {
	// Get a value from the cache given a key.
	//
	// This must be concurrency-safe.
	Get(key string) (interface{}, error)

	// Set a key to value mapping in the cache.
	//
	// This must be concurrency-safe.
	Set(key string, value interface{}) error
}

Interface is the cache interface that all cache implementations must adhere to at the minimum to be usable in the IPinfo client.

Note that all implementations must be concurrency-safe.

Jump to

Keyboard shortcuts

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