redis

package
v3.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conf

type Conf struct {
	Host      string        `json:"host"`
	Port      int           `json:"port"`
	Username  string        `json:"username"`
	Password  string        `json:"password"`
	DB        int           `json:"db"`
	MaxActive int           `json:"max_active"`
	MaxIdle   int           `json:"max_idle"`
	Timeout   time.Duration `json:"timeout"`
	KeyPrefix string        `json:"key_prefix"`
	// If this is set, 'check' and 'close' events will be PUBLISHed to
	// to this Redis key (Redis PubSub).
	PublishKey string `json:"publish_key"`
}

Conf contains Redis configuration fields.

type Redis

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

Redis implements a Redis Store.

func New

func New(c Conf) *Redis

New returns a Redis implementation of store.

func (*Redis) Check

func (r *Redis) Check(namespace, id string, counterKey string) (models.OTP, error)

Check checks the attempt count and TTL duration against an ID. Passing counterKey increments the attempt counter.

func (*Redis) Close

func (r *Redis) Close(namespace, id string) error

Close closes an OTP and marks it as done (verified). After this, the OTP has to expire after a TTL or be deleted.

func (*Redis) Delete

func (r *Redis) Delete(namespace, id string) error

Delete deletes the OTP saved against a given ID.

func (*Redis) Ping

func (r *Redis) Ping() error

Ping checks if Redis server is reachable

func (*Redis) Set

func (r *Redis) Set(namespace, id string, otp models.OTP) (models.OTP, error)

func (*Redis) SetAddress

func (r *Redis) SetAddress(namespace, id, address string) error

SetAddress sets (updates) the address on an existing OTP.

Jump to

Keyboard shortcuts

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