Documentation
¶
Index ¶
- func ParseRedisOptions(redisURL string) (*redis.Options, error)
- func Remember[T any](ctx context.Context, r *Redis, key string, ttl time.Duration, ...) (T, error)
- type Client
- type Redis
- func (r *Redis) Delete(ctx context.Context, keys ...string) error
- func (r *Redis) Exists(ctx context.Context, key string) (bool, error)
- func (r *Redis) Expire(ctx context.Context, key string, ttl time.Duration) (bool, error)
- func (r *Redis) Get(ctx context.Context, key string, dest interface{}) error
- func (r *Redis) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
- func (r *Redis) TTL(ctx context.Context, key string) (time.Duration, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseRedisOptions ¶
ParseRedisOptions parses a redis:// URL into options.
func Remember ¶
func Remember[T any](ctx context.Context, r *Redis, key string, ttl time.Duration, loader func() (T, error)) (T, error)
Remember returns the cached value for key, or runs loader on a cache miss, stores its result with ttl, and returns it. A failure to store the loaded value does not fail the call.
Types ¶
type Redis ¶
type Redis struct {
Client *Client
}
Redis wraps a go-redis client with JSON (de)serialization helpers.
func (*Redis) Delete ¶
Delete removes the given keys. It is a no-op (returns nil) when no keys are given.
func (*Redis) Expire ¶
Expire sets a time-to-live on key. The returned bool reports whether the key existed (and therefore whether the TTL was applied).
Click to show internal directories.
Click to hide internal directories.