cache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitCaches

func InitCaches() error

InitCaches initializes the global cache instances

Types

type Cache

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

Cache represents a simple file-based cache

var (
	// WorkspaceCache for workspace structure (1 hour)
	WorkspaceCache *Cache
	// UserCache for user list (1 hour)
	UserCache *Cache
	// TaskCache for recent tasks (5 minutes)
	TaskCache *Cache
)

Global cache instances with different TTLs

func NewCache

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

NewCache creates a new cache instance

func (*Cache) CleanExpired

func (c *Cache) CleanExpired() (int, error)

CleanExpired removes expired entries from the cache

func (*Cache) Clear

func (c *Cache) Clear() error

Clear removes all items from the cache

func (*Cache) Delete

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

Delete removes an item from the cache

func (*Cache) Get

func (c *Cache) Get(key string, dest interface{}) error

Get retrieves an item from the cache

func (*Cache) GetStats

func (c *Cache) GetStats() (*Stats, error)

GetStats returns statistics about the cache

func (*Cache) Set

func (c *Cache) Set(key string, value interface{}) error

Set stores an item in the cache

type CacheEntry

type CacheEntry struct {
	Data      interface{} `json:"data"`
	ExpiresAt time.Time   `json:"expires_at"`
}

CacheEntry represents a cached item with metadata

type Stats

type Stats struct {
	TotalEntries   int
	ExpiredEntries int
	ValidEntries   int
	TotalSize      int64
	OldestEntry    time.Time
	NewestEntry    time.Time
}

Stats represents cache statistics

Jump to

Keyboard shortcuts

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