session

package
v0.0.0-...-1ae3dfb Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessTimeout  = time.Hour * 24
	CookieSessID = "session_id"
	CookieMaxAge = time.Hour * 24 / time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryStore

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

MemoryStore store sessin in memory

func (*MemoryStore) Create

func (m *MemoryStore) Create(data interface{}) string

Create new session

func (*MemoryStore) Delete

func (m *MemoryStore) Delete(id string) interface{}

Delete session

func (*MemoryStore) Get

func (m *MemoryStore) Get(id string) interface{}

Get session

func (*MemoryStore) Set

func (m *MemoryStore) Set(id string, data interface{}) error

Set session data

func (*MemoryStore) Udpate

func (m *MemoryStore) Udpate(max int) int

Udpate all sessions, if timeout, delete it update `max` items at most each time.

type SessManager

type SessManager struct {
	SessStore
}

SessManager manage all sessions

func GetManager

func GetManager(typ ...StorType) *SessManager

GetManager create an session manager

type SessStore

type SessStore interface {
	// Get session data
	Get(id string) interface{}
	// Set session data
	Set(id string, data interface{}) error
	// Update sessions if timeout, delete it
	Udpate(max int) int

	// Delete session
	Delete(id string) interface{}
	// Create an new session
	Create(data interface{}) string
}

SessStore interface

func NewMemStore

func NewMemStore() SessStore

NewMemStore ...

type StorType

type StorType int

StorType ...

const (
	MemStore   StorType // memory store
	RedisStore          // redis store
)

Jump to

Keyboard shortcuts

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