memcache

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const ProviderName = "memcache"

ProviderName memcache provider name

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ServerList memcache server list
	ServerList []string

	// MaxIdleConns specifies the maximum number of idle connections that will
	// be maintained per address. If less than one, DefaultMaxIdleConns will be
	// used.
	//
	// Consider your expected traffic rates and latency carefully. This should
	// be set to a number higher than your peak parallel requests.
	MaxIdleConns int

	// KeyPrefix sessionID as memcache key prefix
	KeyPrefix string

	// SerializeFunc session value serialize func
	SerializeFunc func(src session.Dict) ([]byte, error)

	// UnSerializeFunc session value unSerialize func
	UnSerializeFunc func(dst *session.Dict, src []byte) error
}

Config session memcache configuration

func (*Config) Name

func (mc *Config) Name() string

Name return provider name

type Provider

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

Provider provider struct

func NewProvider

func NewProvider() *Provider

NewProvider new memcache provider

func (*Provider) Count

func (mcp *Provider) Count() int

Count session values count

func (*Provider) Destroy

func (mcp *Provider) Destroy(sessionID []byte) error

Destroy destroy session by sessionID

func (*Provider) GC

func (mcp *Provider) GC()

GC session memcache provider not need garbage collection

func (*Provider) Get

func (mcp *Provider) Get(sessionID []byte) (session.Storer, error)

Get read session store by session id

func (*Provider) Init

func (mcp *Provider) Init(expiration time.Duration, cfg session.ProviderConfig) error

Init init provider config

func (*Provider) NeedGC

func (mcp *Provider) NeedGC() bool

NeedGC not need gc

func (*Provider) Put

func (mcp *Provider) Put(store session.Storer)

Put put store into the pool.

func (*Provider) Regenerate

func (mcp *Provider) Regenerate(oldID, newID []byte) (session.Storer, error)

Regenerate regenerate session

type Store

type Store struct {
	session.Store
}

Store store struct

func (*Store) Save

func (mcs *Store) Save() error

Save save store

func (*Store) SetExpiration added in v1.1.0

func (mcs *Store) SetExpiration(expiration time.Duration) error

SetExpiration set the expiration for the session

Jump to

Keyboard shortcuts

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