cache

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 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
}

func NewCache

func NewCache(ttl time.Duration) (*Cache, error)

func (*Cache) Clean

func (c *Cache) Clean() error

Clean removes the entire cache

func (*Cache) CleanExpired

func (c *Cache) CleanExpired() error

CleanExpired removes expired cache files

func (*Cache) GenerateHash

func (c *Cache) GenerateHash(content string) string

GenerateHash generates a SHA256 hash of the content

func (*Cache) Get

func (c *Cache) Get(hash string) (json.RawMessage, bool, error)

Get gets a response from the cache

func (*Cache) Set

func (c *Cache) Set(hash string, response interface{}) error

Set saves a response to the cache

type CachedResponse

type CachedResponse struct {
	Hash      string          `json:"hash"`
	Response  json.RawMessage `json:"response"`
	CreatedAt time.Time       `json:"created_at"`
}

Jump to

Keyboard shortcuts

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