Documentation
¶
Overview ¶
Package storage contains the interface that is used to store and retrieve cache entries
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = errors.New("entry not found") ErrBucketNotFound = errors.New("bucket not found") ErrEncoding = errors.New("failed to encode cache entry") ErrDecoding = errors.New("failed to decode cache entry") )
Common errors
Functions ¶
This section is empty.
Types ¶
type CacheEntry ¶
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager manages a single shared cache instance across the application. It ensures thread safety and guarantees only one cache instance exists.
func GetCacheManager ¶
func GetCacheManager() *CacheManager
GetCacheManager returns the global cache manager instance.
func (*CacheManager) Close ¶
func (m *CacheManager) Close() error
Close closes the managed cache instance.
func (*CacheManager) GetCache ¶
func (m *CacheManager) GetCache() (CacheStorage, error)
GetCache returns the shared cache instance, creating it if needed. Thread-safe and ensures only one cache instance exists.
func (*CacheManager) Reset ¶
func (m *CacheManager) Reset() error
Reset clears the manager state (useful for tests).
type CacheStorage ¶
type CacheStorage interface {
Get(ctx context.Context, key string) (CacheEntry, error)
Set(ctx context.Context, key string, value CacheEntry) error
Delete(ctx context.Context, key string) error
Clear(ctx context.Context) error
Close() error
}
func NewBoltCache ¶
func NewBoltCache() (CacheStorage, error)
Click to show internal directories.
Click to hide internal directories.