cache

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2021 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 struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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

func NewInMemTTL

func NewInMemTTL(ttl time.Duration, maxTTL time.Duration) *InMemTTL

NewInMemTTL creates a new TTLed cache.

func (*InMemTTL) Get

func (c *InMemTTL) Get(key string) (string, bool)

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

func (*InMemTTL) Purge

func (c *InMemTTL) Purge()

Purge removes all entries from the cache.

func (*InMemTTL) Remove

func (c *InMemTTL) Remove(key string)

Remove removes a single entry from the cache.

func (*InMemTTL) Set

func (c *InMemTTL) Set(key, value string)

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) Set

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

Set adds an entry to the cache.

Jump to

Keyboard shortcuts

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