cache

package
v1.15.13 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 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 NewOnDiskWithDir added in v1.15.1

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

NewOnDiskWithDir 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.

func (*OnDisk) String added in v1.15.1

func (o *OnDisk) String() string

String return the identity of this cache instance.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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