cache

package
v0.16.18 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(components ...string) string

GenerateKey creates a cache key from multiple string components

Types

type Cache

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

func New

func New(defaultTTL time.Duration) *Cache

func NewWithMaxItems

func NewWithMaxItems(defaultTTL time.Duration, maxItems int) *Cache

NewWithMaxItems creates a cache with a specific maximum number of items

func NewWithMemoryLimit

func NewWithMemoryLimit(defaultTTL time.Duration, maxMemoryMB int) *Cache

NewWithMemoryLimit creates a cache with a specific memory limit

func NewWithoutCleanup

func NewWithoutCleanup(defaultTTL time.Duration) *Cache

NewWithoutCleanup creates a cache without starting the cleanup goroutine Useful for testing or when cleanup is managed externally

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{}, bool)

func (*Cache) Set

func (c *Cache) Set(key string, value interface{}, ttl time.Duration)

func (*Cache) Stats

func (c *Cache) Stats() map[string]interface{}

Jump to

Keyboard shortcuts

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