cache

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cache is used to store values with limits. Items are automatically pruned when too many entries are stored, or values become stale.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAge

func WithAge(age time.Duration) cacheOpts

func WithCount

func WithCount(count int) cacheOpts

Types

type Cache

type Cache[k comparable, v any] struct {
	// contains filtered or unexported fields
}

func New

func New[k comparable, v any](opts ...cacheOpts) Cache[k, v]

func (*Cache[k, v]) Delete

func (c *Cache[k, v]) Delete(key k)

func (*Cache[k, v]) Get

func (c *Cache[k, v]) Get(key k) (v, error)

func (*Cache[k, v]) Set

func (c *Cache[k, v]) Set(key k, val v)

type Entry

type Entry[v any] struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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