Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitGlobalCache ¶
InitGlobalCache initializes the global cache with the given directory.
Types ¶
type BadgerCache ¶
type BadgerCache struct {
// contains filtered or unexported fields
}
BadgerCache implements the Cache interface using Badger DB.
func GetBadgerCache ¶
func GetBadgerCache() (*BadgerCache, bool)
GetBadgerCache returns the global cache as a BadgerCache if applicable.
func NewBadgerCache ¶
func NewBadgerCache(dir string) (*BadgerCache, error)
NewBadgerCache creates a new Badger-based cache.
func (*BadgerCache) Clear ¶
func (c *BadgerCache) Clear() error
Clear removes all items from the cache.
func (*BadgerCache) Delete ¶
func (c *BadgerCache) Delete(key string) error
Delete removes an item from the cache.
type Cache ¶
type Cache interface {
// Get retrieves data from the cache, returning whether it was found
Get(key string, dest interface{}) (bool, error)
// Set stores data in the cache with optional TTL
Set(key string, data interface{}, ttl time.Duration) error
// Delete removes an item from the cache
Delete(key string) error
// Clear removes all items from the cache
Clear() error
// Close closes the cache and releases any resources
Close() error
}
Cache defines the interface for the caching system.
type CacheItem ¶
type CacheItem struct {
Data interface{} `json:"data"`
Timestamp int64 `json:"timestamp"`
TTL int64 `json:"ttl"` // TTL in seconds, 0 means no expiration
}
CacheItem represents an item in the cache with TTL.
type FileCache ¶
type FileCache struct {
// contains filtered or unexported fields
}
FileCache implements a simple file-based cache.
func NewFileCache ¶
NewFileCache creates a new file-based cache.
func NewMemoryCache ¶
func NewMemoryCache() *FileCache
NewMemoryCache creates an in-memory only cache (no persistence).
func (*FileCache) Close ¶
Close implements the Cache.Close method for FileCache This is a no-op for FileCache since it doesn't maintain any resources that need explicit closing.