cache

package
v1.14.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMemTTL

type InMemTTL[K comparable, V any] struct {
	sync.Mutex
	// contains filtered or unexported fields
}

InMemTTL implements a simple TTLed cache in memory. It is concurrency safe.

func NewInMemTTL

func NewInMemTTL[K comparable, V any](ttl time.Duration, maxTTL time.Duration) *InMemTTL[K, V]

NewInMemTTL creates a new TTLed cache.

func (*InMemTTL[K, V]) Get

func (c *InMemTTL[K, V]) Get(key K) (V, bool)

Get retrieves a single entry, extending it's TTL.

func (*InMemTTL[K, V]) Purge

func (c *InMemTTL[K, V]) Purge()

Purge removes all entries from the cache.

func (*InMemTTL[K, V]) Remove

func (c *InMemTTL[K, V]) Remove(key K)

Remove removes a single entry from the cache.

func (*InMemTTL[K, V]) Set

func (c *InMemTTL[K, V]) Set(key K, value V)

Set creates or overwrites an entry.

type OnDisk

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

OnDisk is a simple on disk cache.

func NewOnDisk

func NewOnDisk(name string, ttl time.Duration) (*OnDisk, error)

NewOnDisk creates a new on disk cache.

func (*OnDisk) Get

func (o *OnDisk) Get(key string) ([]string, error)

Get fetches an entry from the cache.

func (*OnDisk) ModTime added in v1.14.0

func (o *OnDisk) ModTime(key string) time.Time

ModTime returns the modification time of the cache entry.

func (*OnDisk) Purge added in v1.14.0

func (o *OnDisk) Purge() error

Purge removes all entries from the cache.

func (*OnDisk) Remove added in v1.14.0

func (o *OnDisk) Remove(key string) error

Remove removes an entry from the cache.

func (*OnDisk) Set

func (o *OnDisk) Set(key string, value []string) error

Set adds an entry to the cache.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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