Documentation
¶
Index ¶
- func GetTyped[T any](c Cache, key string) (T, error)
- func MustGet[T any](c Cache, key string) T
- type BadgerCache
- func (b *BadgerCache) EmptyByMatch(str string) error
- func (b *BadgerCache) Flush() error
- func (b *BadgerCache) Forget(str string) error
- func (b *BadgerCache) Get(str string) (interface{}, error)
- func (b *BadgerCache) Has(str string) (bool, error)
- func (b *BadgerCache) Set(str string, value interface{}, ttl ...int) error
- type Cache
- type Entry
- type RedisCache
- func (c *RedisCache) EmptyByMatch(str string) error
- func (c *RedisCache) Flush() error
- func (c *RedisCache) Forget(str string) error
- func (c *RedisCache) Get(str string) (interface{}, error)
- func (c *RedisCache) Has(str string) (bool, error)
- func (c *RedisCache) Set(str string, value interface{}, ttl ...int) error
- type TypedCache
- func (tc *TypedCache[T]) EmptyByMatch(pattern string) error
- func (tc *TypedCache[T]) Flush() error
- func (tc *TypedCache[T]) Forget(key string) error
- func (tc *TypedCache[T]) Get(key string) (T, error)
- func (tc *TypedCache[T]) Has(key string) (bool, error)
- func (tc *TypedCache[T]) Set(key string, value T, ttl ...int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BadgerCache ¶
func (*BadgerCache) EmptyByMatch ¶
func (b *BadgerCache) EmptyByMatch(str string) error
func (*BadgerCache) Flush ¶
func (b *BadgerCache) Flush() error
func (*BadgerCache) Forget ¶
func (b *BadgerCache) Forget(str string) error
func (*BadgerCache) Get ¶
func (b *BadgerCache) Get(str string) (interface{}, error)
type RedisCache ¶
func (*RedisCache) EmptyByMatch ¶
func (c *RedisCache) EmptyByMatch(str string) error
func (*RedisCache) Flush ¶
func (c *RedisCache) Flush() error
func (*RedisCache) Forget ¶
func (c *RedisCache) Forget(str string) error
func (*RedisCache) Get ¶
func (c *RedisCache) Get(str string) (interface{}, error)
type TypedCache ¶
type TypedCache[T any] struct { // contains filtered or unexported fields }
TypedCache provides a type-safe wrapper around the Cache interface. Example:
userCache := NewTypedCache[User](redisCache)
userCache.Set("user:123", user, 3600)
user, err := userCache.Get("user:123")
func NewTypedCache ¶
func NewTypedCache[T any](c Cache) *TypedCache[T]
NewTypedCache creates a new type-safe cache wrapper.
func (*TypedCache[T]) EmptyByMatch ¶
func (tc *TypedCache[T]) EmptyByMatch(pattern string) error
EmptyByMatch removes all keys matching the pattern.
func (*TypedCache[T]) Flush ¶
func (tc *TypedCache[T]) Flush() error
Flush removes all entries from the cache.
func (*TypedCache[T]) Forget ¶
func (tc *TypedCache[T]) Forget(key string) error
Forget removes a key from the cache.
func (*TypedCache[T]) Get ¶
func (tc *TypedCache[T]) Get(key string) (T, error)
Get retrieves a typed value from the cache.
Click to show internal directories.
Click to hide internal directories.