Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a generic in-memory cache with a max size and LRU management
type CacheEntry ¶
CacheEntry represents a generic cache entry with a timestamp
type CacheWrapperT ¶
type CacheWrapperT struct {
Cache *Cache
}
CacheWrapper provides an easy interface for caching with SQLC queries
var CacheWrapper *CacheWrapperT
func NewCacheWrapper ¶
func NewCacheWrapper(maxSize int) *CacheWrapperT
NewCacheWrapper creates a new CacheWrapper with a specified cache size
func (*CacheWrapperT) DeferredWrite ¶
func (cw *CacheWrapperT) DeferredWrite(key string, data interface{}, dbWriteFunc func(context.Context, interface{}) error)
DeferredWrite stores data in cache and writes to the database asynchronously
func (*CacheWrapperT) GetWithCache ¶
func (cw *CacheWrapperT) GetWithCache(ctx context.Context, key string, dbFunc func(context.Context) (interface{}, error)) (interface{}, error)
GetWithCache tries to retrieve the data from cache or falls back to DB function
Click to show internal directories.
Click to hide internal directories.