Documentation ¶
Index ¶
- func InMemProvider(ctx context.Context, config *viper.Viper) (providers.Cache, error)
- func InMemStreamProvider(ctx context.Context, config *viper.Viper) (providers.Stream, error)
- func Provider(ctx context.Context, config *viper.Viper) (providers.Cache, error)
- func StreamProvider(ctx context.Context, config *viper.Viper) (providers.Stream, error)
- type Redis
- func (r Redis) AsyncSubscribe(ctx context.Context, topic, consumer string, handler providers.MessageHandler) error
- func (r Redis) Delete(ctx context.Context, key string) error
- func (r Redis) Get(ctx context.Context, key string) (string, error)
- func (r Redis) Lock(ctx context.Context, key string, ttl time.Duration) (bool, error)
- func (r Redis) Once(ctx context.Context, key string, ttl time.Duration, ...) (bool, error)
- func (r Redis) Publish(ctx context.Context, topic string, message map[string]any) error
- func (r Redis) Set(ctx context.Context, key string, value string, ttl time.Duration) error
- func (r Redis) Subscribe(ctx context.Context, topic, consumer string, handler providers.MessageHandler) error
- func (r Redis) Unlock(ctx context.Context, key string, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InMemProvider ¶
InMemProvider returns a new in-memory redis provider(used for testing)
func InMemStreamProvider ¶
InMemProvider returns a new in-memory redis stream provider(used for testing)
Types ¶
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
func NewRedis ¶
func NewRedis(client *redis.Client) *Redis
NewRedis returns a new redis cache/stream provider
func (Redis) AsyncSubscribe ¶
func (r Redis) AsyncSubscribe(ctx context.Context, topic, consumer string, handler providers.MessageHandler) error
AsyncSubscribe subscribes to a topic and calls the handler in a goroutine
func (Redis) Once ¶
func (r Redis) Once(ctx context.Context, key string, ttl time.Duration, fn func(ctx context.Context) error) (bool, error)
Once runs a function once for a given key
Click to show internal directories.
Click to hide internal directories.