cache

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitTTL     = 2 * time.Second
	ProcessTTL = 2 * time.Second
	ConfigTTL  = 10 * time.Second
)

Common TTL constants

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache provides thread-safe in-memory caching with TTL

func New

func New() *Cache

New creates a new cache instance

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all items from the cache

func (*Cache) Delete

func (c *Cache) Delete(key string)

Delete removes a key from the cache

func (*Cache) DeleteByPrefix

func (c *Cache) DeleteByPrefix(prefix string)

DeleteByPrefix removes all keys with the given prefix

func (*Cache) Get

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

Get retrieves a value from the cache Returns the value and true if found and not expired, empty string and false otherwise

func (*Cache) IsStale

func (c *Cache) IsStale(key string, ttl time.Duration) bool

IsStale returns true if the key is missing or expired

func (*Cache) Set

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

Set stores a value in the cache with the given TTL

Jump to

Keyboard shortcuts

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