memcachedstore

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: 3 Imported by: 2

README

Memcached Store for Captchas

$ go get clevergo.tech/captchas/stores/memcachedstore
import (
	"clevergo.tech/captchas/stores/memcachedstore"
	"github.com/bradfitz/gomemcache/memcache"
)
// client.
client := memcache.New("localhost:11211")
store := memcachedstore.New(
	client,
	memcachedstore.Expiration(int32(600)), // captcha expiration, optional.
	memcachedstore.Prefix("captchas"),     // 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 memcached store.

func Expiration

func Expiration(expiration int32) Option

Expiration sets the expiration of captcha.

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 memcached store.

func New

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

New returns a memcache 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.Get.

Jump to

Keyboard shortcuts

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