redis

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisClientWithLoadbalancer added in v1.2.0

func NewRedisClientWithLoadbalancer(addrs []string, opt *redis.Options) (*redis.Client, *loadbalancer)

Create a new redis client with loadbalanced connections

func NewRedisLoadbalancer added in v1.2.0

func NewRedisLoadbalancer(addrs []string, opt redis.Options) *loadbalancer

Return a new loadbalancer for redis

Types

type RedisBackend

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

func NewRedisBackend

func NewRedisBackend(cfg RedisConfig) (*RedisBackend, error)

func (*RedisBackend) Close

func (r *RedisBackend) Close() error

Calls all necessary finalization if necessary

func (*RedisBackend) GetLocks

func (r *RedisBackend) GetLocks(group string) (int, error)

Returns the current number of locks for the given group

func (*RedisBackend) GetStaleLocks

func (r *RedisBackend) GetStaleLocks(ts time.Duration) ([]types.Lock, error)

Return all locks older than x

func (*RedisBackend) HasLock

func (r *RedisBackend) HasLock(group string, id string) (bool, error)

Check if a given id already has a lock for this group

func (*RedisBackend) Release

func (r *RedisBackend) Release(group string, id string) error

Release the lock currently held by the id. Does not fail when no lock is held.

func (*RedisBackend) Reserve

func (r *RedisBackend) Reserve(group string, id string) error

Reserve a lock for the given group. Returns true if the lock is successfully reserved, even if the lock is already held by the specific id

type RedisConfig

type RedisConfig struct {
	Addr     string              `yaml:"address,omitempty"`
	Addrs    []string            `yaml:"addresses,omitempty"`
	Username string              `yaml:"username,omitempty"`
	Password string              `yaml:"password,omitempty"`
	DB       int                 `yaml:"db,omitempty"`
	TLS      bool                `yaml:"tls,omitempty"`
	Sentinel RedisSentinelConfig `yaml:"sentinel,omitempty"`
}

type RedisSentinelConfig added in v1.2.0

type RedisSentinelConfig struct {
	Enabled    bool     `yaml:"enabled,omitempty"`
	MasterName string   `yaml:"master,omitempty"`
	Addresses  []string `yaml:"addresses,omitempty"`
	Username   string   `yaml:"username,omitempty"`
	Password   string   `yaml:"password,omitempty"`
}

Jump to

Keyboard shortcuts

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