Documentation ¶
Index ¶
- type Cache
- type CacheConfig
- type LocalCacheRistretto
- func (c *LocalCacheRistretto) Delete(ctx context.Context, key string) error
- func (c *LocalCacheRistretto) Expire(ctx context.Context, key string, ttl time.Duration) error
- func (c *LocalCacheRistretto) Get(ctx context.Context, key string) (any, bool)
- func (c *LocalCacheRistretto) Set(ctx context.Context, key string, value any) error
- func (c *LocalCacheRistretto) SetWithTTL(ctx context.Context, key string, value any, ttl time.Duration) error
- type RemoteCacheValkey
- func (c *RemoteCacheValkey) Delete(ctx context.Context, key string) error
- func (c *RemoteCacheValkey) Expire(ctx context.Context, key string, ttl time.Duration) error
- func (c *RemoteCacheValkey) Get(ctx context.Context, key string) (interface{}, bool)
- func (c *RemoteCacheValkey) Set(ctx context.Context, key string, value interface{}) error
- func (c *RemoteCacheValkey) SetWithTTL(ctx context.Context, key string, value interface{}, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Returns the value for the given key. // If the key is not found, it returns nil and false. Get(ctx context.Context, key string) (any, bool) // Sets the value for the given key. // If the key already exists, it returns an error. Set(ctx context.Context, key string, value any) error // Deletes the value for the given key. // If the key is not found, it returns an error. Delete(ctx context.Context, key string) error // Sets the expiration time for the given key. Expire(ctx context.Context, key string, ttl time.Duration) error // Sets the value for the given key with a specific TTL. SetWithTTL(ctx context.Context, key string, value any, ttl time.Duration) error }
Cache is the interface that defines the caching operations.
func NewCache ¶
func NewCache(cacheCfg *CacheConfig) (Cache, func())
type CacheConfig ¶
type LocalCacheRistretto ¶
type LocalCacheRistretto struct {
// contains filtered or unexported fields
}
LocalCache is an implementation of Cache that uses Ristretto.
func NewLocalCacheRistretto ¶
func NewLocalCacheRistretto(cacheCfg *CacheConfig) (*LocalCacheRistretto, func())
func (*LocalCacheRistretto) Delete ¶ added in v0.0.5
func (c *LocalCacheRistretto) Delete(ctx context.Context, key string) error
func (*LocalCacheRistretto) SetWithTTL ¶
type RemoteCacheValkey ¶
type RemoteCacheValkey struct {
// contains filtered or unexported fields
}
RemoteCache is an implementation of Cache that uses Redis.
func NewRemoteCacheValkey ¶
func NewRemoteCacheValkey(cacheCfg *CacheConfig) (*RemoteCacheValkey, func())
func (*RemoteCacheValkey) Delete ¶ added in v0.0.5
func (c *RemoteCacheValkey) Delete(ctx context.Context, key string) error
func (*RemoteCacheValkey) Get ¶
func (c *RemoteCacheValkey) Get(ctx context.Context, key string) (interface{}, bool)
func (*RemoteCacheValkey) Set ¶
func (c *RemoteCacheValkey) Set(ctx context.Context, key string, value interface{}) error
func (*RemoteCacheValkey) SetWithTTL ¶
Click to show internal directories.
Click to hide internal directories.