memstore

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

Memory Store for Captchas

$ go get clevergo.tech/captchas/stores/memstore
store := memstore.New(
	memstore.Expiration(10*time.Minute), // captcha expiration, optional.
	memstore.GCInterval(time.Minute), // garbage collection interval to delete expired captcha, optional.
)

Inspired by scs.memstore.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Store)

Option is a function that receives a pointer of store.

func Expiration

func Expiration(expiration time.Duration) Option

Expiration sets expiration.

func GCInterval

func GCInterval(interval time.Duration) Option

GCInterval sets garbage collection .

type Store

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

Store is a memory store.

func New

func New(opts ...Option) *Store

New returns a memory 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, answer string) error

Set implements Store.Set.

Jump to

Keyboard shortcuts

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