cache

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 4 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 {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(config Config) *Cache

func (*Cache) Clear

func (c *Cache) Clear()

func (*Cache) Close

func (c *Cache) Close()

func (*Cache) Delete

func (c *Cache) Delete(key CacheKey)

func (*Cache) Get

func (c *Cache) Get(key CacheKey) (interface{}, bool)

func (*Cache) GetStats

func (c *Cache) GetStats() CacheStats

func (*Cache) Set

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

type CacheEntry

type CacheEntry struct {
	Value      interface{}
	Expiration time.Time
}

type CacheKey

type CacheKey string

type CacheStats

type CacheStats struct {
	Size    int
	Hits    int64
	Misses  int64
	Evicted int64
}

type Config

type Config struct {
	MaxSize       int
	TTL           time.Duration
	CleanupPeriod time.Duration
}

Jump to

Keyboard shortcuts

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