ttlcache

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache implements TTL-based cache with memory limits

func New

func New(ttl time.Duration, maxSize int) *Cache

New creates a cache with TTL and max size

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all items

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes item from cache

func (*Cache) Get

func (c *Cache) Get(key string) (any, bool)

Get retrieves item from cache

func (*Cache) Set

func (c *Cache) Set(key string, value any, size int)

Set adds item to cache

func (*Cache) Stats

func (c *Cache) Stats() (items, size int)

Stats returns cache statistics

Jump to

Keyboard shortcuts

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