redisstore

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: BSD-3-Clause Imports: 4 Imported by: 2

README

Redis Store for Captchas

$ go get clevergo.tech/captchas/stores/redisstore
import (
    "clevergo.tech/captchas/stores/redisstore"
    "github.com/go-redis/redis/v7"
)
// redis client.
client := redis.NewClient(&redis.Options{
	Addr: "localhost:6379",
})
store := redisstore.New(
	client,
	redisstore.Expiration(10*time.Minute), // captcha expiration, optional.
	redisstore.Prefix("captchas"), // redis key prefix, optional.
)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(s *Store)

Option is a function that receives a pointer of redis store.

func Expiration

func Expiration(expiration time.Duration) Option

Expiration sets the expiration.

func Prefix

func Prefix(prefix string) Option

Prefix sets the prefix of key.

type Store

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

Store is a redis store.

func New

func New(client *redis.Client, opts ...Option) *Store

New returns a redis store.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string, clear bool) (string, error)

Get implements Store.Get.

func (*Store) Set

func (s *Store) Set(ctx context.Context, id string, value string) error

Set implements Store.Set.

Jump to

Keyboard shortcuts

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