redis

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InMemProvider

func InMemProvider(ctx context.Context, config *viper.Viper) (providers.Cache, error)

InMemProvider returns a new in-memory redis provider(used for testing)

func InMemStreamProvider

func InMemStreamProvider(ctx context.Context, config *viper.Viper) (providers.Stream, error)

InMemProvider returns a new in-memory redis stream provider(used for testing)

func Provider

func Provider(ctx context.Context, config *viper.Viper) (providers.Cache, error)

Provider returns a new Redis cache provider

func StreamProvider

func StreamProvider(ctx context.Context, config *viper.Viper) (providers.Stream, error)

StreamProvider returns a new Redis stream provider

Types

type Redis

type Redis struct {
	// contains filtered or unexported fields
}

func NewRedis

func NewRedis(client *redis.Client) *Redis

func (Redis) AsyncSubscribe

func (r Redis) AsyncSubscribe(ctx context.Context, topic, consumer string, handler providers.MessageHandler) error

func (Redis) Delete

func (r Redis) Delete(ctx context.Context, key string) error

func (Redis) Get

func (r Redis) Get(ctx context.Context, key string) (string, error)

func (Redis) Lock

func (r Redis) Lock(ctx context.Context, key string, ttl time.Duration) (bool, error)

func (Redis) Once

func (r Redis) Once(ctx context.Context, key string, ttl time.Duration, fn func(ctx context.Context) error) (bool, error)

func (Redis) Publish

func (r Redis) Publish(ctx context.Context, topic string, message map[string]any) error

func (Redis) Set

func (r Redis) Set(ctx context.Context, key string, value string, ttl time.Duration) error

func (Redis) Subscribe

func (r Redis) Subscribe(ctx context.Context, topic, consumer string, handler providers.MessageHandler) error

func (Redis) Unlock

func (r Redis) Unlock(ctx context.Context, key string, ttl time.Duration) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL