cache

package
v0.0.0-...-5321e6f Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCacheSize    = 1024
	DefaultCacheItemTTL = 60000000000 // 1 minute in nanoseconds
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// The maximum size of the cache.
	MaxCacheSize int
	// The time-to-live for cache entries in nanoseconds.
	CacheEntryTTL time.Duration
	// contains filtered or unexported fields
}

Cache is a basic thread-safe in-memory LRU cache. It is thread-safe and is used as the default items if providers

func New

func New() *Cache

New creates a new cache with default settings.

func NewCache

func NewCache(maxCacheSize int, cacheEntryTTL time.Duration) *Cache

NewCache creates a new cache with the specified max size and entry TTL.

func (*Cache) Clear

func (c *Cache) Clear()

func (*Cache) Delete

func (c *Cache) Delete(key string)

func (*Cache) Get

func (c *Cache) Get(key string) interface{}

func (*Cache) Set

func (c *Cache) Set(key string, value interface{})

Jump to

Keyboard shortcuts

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