Documentation
¶
Index ¶
- Variables
- type Entry
- type FileStore
- func (fs *FileStore) Clear(ctx context.Context) error
- func (fs *FileStore) Delete(ctx context.Context, key string) error
- func (fs *FileStore) Get(ctx context.Context, key string) ([]byte, error)
- func (fs *FileStore) IsExpired(ctx context.Context, key string) (bool, error)
- func (fs *FileStore) Set(ctx context.Context, key string, data []byte, ttl time.Duration) error
- type Store
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrCacheMiss indicates the requested key was not found in cache. ErrCacheMiss = errors.New("cache miss") // ErrCacheExpired indicates the cached entry has expired. ErrCacheExpired = errors.New("cache expired") )
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Data []byte `json:"data"`
CachedAt time.Time `json:"cached_at"`
ExpiresAt time.Time `json:"expires_at"`
}
Entry represents a cached entry with metadata.
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore implements file-based caching.
func NewFileStore ¶
NewFileStore creates a new file-based cache store.
type Store ¶
type Store interface {
// Get retrieves data from cache. Returns ErrCacheMiss if not found or expired.
Get(ctx context.Context, key string) ([]byte, error)
// Set stores data in cache with the specified TTL.
Set(ctx context.Context, key string, data []byte, ttl time.Duration) error
// Delete removes an entry from cache.
Delete(ctx context.Context, key string) error
// Clear removes all entries from cache.
Clear(ctx context.Context) error
// IsExpired checks if a cache entry is expired without reading it.
IsExpired(ctx context.Context, key string) (bool, error)
}
Store defines the interface for cache operations.
Click to show internal directories.
Click to hide internal directories.