redis

package
v4.75.4 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: MIT Imports: 17 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDisabled = errors.New("redis not enabled")
View Source
var ErrNoSubscriber = errors.New("no subscriber for channel")

Functions

func PullFor added in v4.44.0

func PullFor[T any](ctx context.Context, client Client, key string, handler func(T, error))

func SubscribeFor added in v4.44.0

func SubscribeFor[T any](ctx context.Context, client Subscriber, channel string, handler func(T, error))

Types

type Client added in v4.52.6

type Client interface {
	Subscriber

	Enabled() bool
	Close()
	FlushAll(context.Context) error
	Ping(ctx context.Context) error
	Load(ctx context.Context, key string) ([]byte, error)
	LoadMany(ctx context.Context, keys ...string) ([]string, error)
	Store(ctx context.Context, key string, value any, ttl time.Duration) error
	StoreMany(ctx context.Context, values map[string]any, ttl time.Duration) error
	Delete(ctx context.Context, keys ...string) error
	DeletePattern(ctx context.Context, pattern string) error
	Scan(ctx context.Context, pattern string, output chan<- string, pageSize int64) error
	Exclusive(ctx context.Context, name string, timeout time.Duration, action func(context.Context) error) (bool, error)
	Expire(ctx context.Context, ttl time.Duration, keys ...string) error
	Push(ctx context.Context, key string, value any) error
	Pull(ctx context.Context, key string, handler func(string, error))
	Publish(ctx context.Context, channel string, value any) error
	PublishJSON(ctx context.Context, channel string, value any) error
	Pipeline() redis.Pipeliner
}

func New

func New(config *Config, meter metric.MeterProvider, tracer trace.TracerProvider) (Client, error)

type Config

type Config struct {
	Username    string
	Password    string
	Address     []string
	Database    int
	PoolSize    int
	MinIdleConn int
}

func Flags

func Flags(fs *flag.FlagSet, prefix string, overrides ...flags.Override) *Config

type Noop added in v4.60.0

type Noop struct{}

func (Noop) Close added in v4.60.0

func (n Noop) Close()

func (Noop) Delete added in v4.60.0

func (n Noop) Delete(_ context.Context, _ ...string) error

func (Noop) DeletePattern added in v4.60.0

func (n Noop) DeletePattern(_ context.Context, _ string) error

func (Noop) Enabled added in v4.60.0

func (n Noop) Enabled() bool

func (Noop) Exclusive added in v4.60.0

func (n Noop) Exclusive(_ context.Context, _ string, _ time.Duration, _ func(context.Context) error) (bool, error)

func (Noop) Expire added in v4.60.0

func (n Noop) Expire(_ context.Context, _ time.Duration, _ ...string) error

func (Noop) FlushAll added in v4.63.0

func (n Noop) FlushAll(_ context.Context) error

func (Noop) Load added in v4.60.0

func (n Noop) Load(_ context.Context, _ string) ([]byte, error)

func (Noop) LoadMany added in v4.60.0

func (n Noop) LoadMany(_ context.Context, keys ...string) ([]string, error)

func (Noop) Ping added in v4.60.0

func (n Noop) Ping(_ context.Context) error

func (Noop) Pipeline added in v4.60.0

func (n Noop) Pipeline() redis.Pipeliner

func (Noop) Publish added in v4.60.0

func (n Noop) Publish(_ context.Context, _ string, _ any) error

func (Noop) PublishJSON added in v4.60.0

func (n Noop) PublishJSON(_ context.Context, _ string, _ any) error

func (Noop) Pull added in v4.60.0

func (n Noop) Pull(_ context.Context, _ string, _ func(string, error))

func (Noop) Push added in v4.60.0

func (n Noop) Push(_ context.Context, _ string, _ any) error

func (Noop) Scan added in v4.60.0

func (n Noop) Scan(_ context.Context, _ string, output chan<- string, _ int64) error

func (Noop) Store added in v4.60.0

func (n Noop) Store(_ context.Context, _ string, _ any, _ time.Duration) error

func (Noop) StoreMany added in v4.65.0

func (n Noop) StoreMany(_ context.Context, _ map[string]any, _ time.Duration) error

func (Noop) Subscribe added in v4.60.0

func (n Noop) Subscribe(_ context.Context, _ string) (<-chan *redis.Message, func(context.Context))

type Service added in v4.64.0

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

func (*Service) Close added in v4.64.0

func (s *Service) Close()

func (*Service) Delete added in v4.64.0

func (s *Service) Delete(ctx context.Context, keys ...string) (err error)

func (*Service) DeletePattern added in v4.64.0

func (s *Service) DeletePattern(ctx context.Context, pattern string) (err error)

func (*Service) Enabled added in v4.64.0

func (s *Service) Enabled() bool

func (*Service) Exclusive added in v4.64.0

func (s *Service) Exclusive(ctx context.Context, name string, timeout time.Duration, action func(context.Context) error) (acquired bool, err error)

func (*Service) Expire added in v4.64.0

func (s *Service) Expire(ctx context.Context, ttl time.Duration, keys ...string) error

func (*Service) FlushAll added in v4.64.0

func (s *Service) FlushAll(ctx context.Context) error

func (*Service) Load added in v4.64.0

func (s *Service) Load(ctx context.Context, key string) ([]byte, error)

func (*Service) LoadMany added in v4.64.0

func (s *Service) LoadMany(ctx context.Context, keys ...string) ([]string, error)

func (*Service) Ping added in v4.64.0

func (s *Service) Ping(ctx context.Context) error

func (*Service) Pipeline added in v4.64.0

func (s *Service) Pipeline() redis.Pipeliner

func (Service) Publish added in v4.64.0

func (s Service) Publish(ctx context.Context, channel string, value any) (err error)

func (Service) PublishJSON added in v4.64.0

func (s Service) PublishJSON(ctx context.Context, channel string, value any) error

func (Service) Pull added in v4.64.0

func (s Service) Pull(ctx context.Context, key string, handler func(string, error))

func (Service) Push added in v4.64.0

func (s Service) Push(ctx context.Context, key string, value any) error

func (*Service) Scan added in v4.64.0

func (s *Service) Scan(ctx context.Context, pattern string, output chan<- string, pageSize int64) error

func (*Service) Store added in v4.64.0

func (s *Service) Store(ctx context.Context, key string, value any, ttl time.Duration) error

func (*Service) StoreMany added in v4.65.0

func (s *Service) StoreMany(ctx context.Context, values map[string]any, ttl time.Duration) error

func (Service) Subscribe added in v4.64.0

func (s Service) Subscribe(ctx context.Context, channel string) (<-chan *redis.Message, func(context.Context))

type Subscriber added in v4.66.0

type Subscriber interface {
	Subscribe(ctx context.Context, channel string) (<-chan *redis.Message, func(context.Context))
}

Jump to

Keyboard shortcuts

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