cache

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(input string) string

Types

type Cache

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

func NewCache

func NewCache(store storage.Storage) *Cache

func NewCacheWithConfig added in v0.3.0

func NewCacheWithConfig(store storage.Storage, config *Config) *Cache

func (*Cache) Clear added in v0.3.0

func (c *Cache) Clear(ctx context.Context) error

Clear removes all entries from the cache

func (*Cache) Count added in v0.3.0

func (c *Cache) Count() int

Count returns the number of entries in the cache

func (*Cache) Delete added in v0.3.0

func (c *Cache) Delete(ctx context.Context, key string) error

Delete removes an entry from the cache

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) ([]byte, bool, error)

func (*Cache) GetConfig added in v0.3.0

func (c *Cache) GetConfig() *Config

GetConfig returns the cache configuration

func (*Cache) Set

func (c *Cache) Set(ctx context.Context, key string, response []byte, ttl time.Duration) error

func (*Cache) Stop added in v0.3.0

func (c *Cache) Stop()

Stop stops the background cleanup goroutine

type CacheItem

type CacheItem struct {
	Response  []byte        `json:"response"`
	CreatedAt time.Time     `json:"created_at"`
	TTL       time.Duration `json:"ttl"`
}

type Config added in v0.3.0

type Config struct {
	TTL             time.Duration
	MaxEntries      int
	CleanupInterval time.Duration
}

Config holds cache configuration

func DefaultConfig added in v0.3.0

func DefaultConfig() *Config

DefaultConfig returns default cache configuration

Jump to

Keyboard shortcuts

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