cache

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cache contains caching implementation for retrieved data

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyNotFound = errors.New("requested key was not found in database")

ErrKeyNotFound signalized the key is not present in the cache

Functions

This section is empty.

Types

type Cache

type Cache interface {
	Get(namespace, key string) (value string, err error)
	Set(namespace, key, value string, ttl time.Duration) (err error)
	Delete(namespace, key string) (err error)
}

Cache describes an interface used to store generated data

func GetCacheByURI

func GetCacheByURI(uri string) (Cache, error)

GetCacheByURI instantiates a new Cache by the given URI string

type InMemCache

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

InMemCache implements the Cache interface for storage in memory

func NewInMemCache

func NewInMemCache() *InMemCache

NewInMemCache creates a new InMemCache

func (*InMemCache) Delete

func (i *InMemCache) Delete(namespace, key string) (err error)

Delete deletes data

func (*InMemCache) Get

func (i *InMemCache) Get(namespace, key string) (value string, err error)

Get retrieves stored data

func (*InMemCache) Set

func (i *InMemCache) Set(namespace, key, value string, ttl time.Duration) (err error)

Set stores data

Jump to

Keyboard shortcuts

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