Documentation
¶
Index ¶
- type Cache
- func (c *Cache) Clear()
- func (c *Cache) Delete(key string)
- func (c *Cache) Exists(key string) bool
- func (c *Cache) Get(key string) (any, bool)
- func (c *Cache) GetBytes(key string) ([]byte, bool)
- func (c *Cache) GetString(key string) (string, bool)
- func (c *Cache) Set(key string, value any, ttl time.Duration)
- func (c *Cache) SetBytes(key string, value []byte, ttl time.Duration)
- func (c *Cache) SetString(key string, value string, ttl time.Duration)
- func (c *Cache) Size() int
- func (c *Cache) Stats() CacheStats
- type CacheStats
- type CacheWithLoader
- type TypedCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a thread-safe in-memory cache with TTL support
type CacheStats ¶
CacheStats holds cache statistics
type CacheWithLoader ¶
type CacheWithLoader struct {
*Cache
// contains filtered or unexported fields
}
CacheWithLoader is a cache that can load missing values
func NewWithLoader ¶
func NewWithLoader(maxSize int, defaultTTL time.Duration, loader func(key string) (any, error)) *CacheWithLoader
NewWithLoader creates a cache with a loader function
type TypedCache ¶
TypedCache is a type-safe wrapper around Cache
func NewTyped ¶
func NewTyped[T any](maxSize int, defaultTTL time.Duration) *TypedCache[T]
NewTyped creates a new typed cache
func (*TypedCache[T]) Get ¶
func (c *TypedCache[T]) Get(key string) (T, bool)
Get retrieves a typed value from the cache
Click to show internal directories.
Click to hide internal directories.