cache

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 7 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 provides simple file-based caching

func New

func New(dir string, ttl time.Duration) *Cache

New creates a new cache instance

func (*Cache) Cleanup

func (c *Cache) Cleanup() error

Cleanup removes expired cache entries

func (*Cache) Clear

func (c *Cache) Clear() error

Clear removes all cached items

func (*Cache) Delete

func (c *Cache) Delete(key string) error

Delete removes an item from the cache

func (*Cache) GenerateKey

func (c *Cache) GenerateKey(prefix string, params map[string]interface{}) string

GenerateKey creates a cache key from parameters

func (*Cache) Get

func (c *Cache) Get(key string) ([]byte, bool)

Get retrieves an item from the cache

func (*Cache) Set

func (c *Cache) Set(key string, data []byte) error

Set stores an item in the cache

func (*Cache) Stats

func (c *Cache) Stats() (total int, size int64, err error)

Stats returns cache statistics

type CacheEntry

type CacheEntry struct {
	Data      []byte    `json:"data"`
	CreatedAt time.Time `json:"created_at"`
	TTL       int       `json:"ttl"`
}

CacheEntry represents a cached item

Jump to

Keyboard shortcuts

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