session

package
v0.0.0-...-5342816 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GC

func GC() error

GC starts to garbage collection

func Get

func Get(ctx context.Context, id string) (interface{}, error)

Get returns a session by its id

func GetCache

func GetCache(ctx context.Context, id string) ([]byte, error)

GetCache gets the session data by its id

func InitSession

func InitSession(cfg config.SessionConfig) error

InitSession inits the session defined in the config file

func New

func New(ctx context.Context, id string) (string, error)

New creates a new session and gets the id string

func PutCache

func PutCache(ctx context.Context, id string, data []byte) error

PutCache puts the session data by its id

func Register

func Register(name string, driver Driver) error

Register regists a driver

func Release

func Release(ctx context.Context, id string) error

Release frees the resource of a session by its id and removes the id

Types

type Driver

type Driver interface {
	// Init setups a driver
	Init(paras map[string]interface{}) error
	// New creates a new session and gets the id string
	New(ctx context.Context, id string) (string, error)
	// Get returns a session by its id
	Get(ctx context.Context, id string) (interface{}, error)
	// Release frees the resource of a session by its id and removes the id
	Release(ctx context.Context, id string) error

	// Should merge to 'Get' and add 'name' paras
	// GetCache gets the session data by its id
	GetCache(ctx context.Context, id string) ([]byte, error)
	// PutCache puts the session data by its id
	PutCache(ctx context.Context, id string, data []byte) error
	// GC starts to garbage collection
	GC() error
}

Driver provides the session interfaces

type Record

type Record struct {
}

Record provides interface to manage a session detailed info, such like expiring data

func NewRecordFromContext

func NewRecordFromContext(ctx context.Context) Record

NewRecordFromContext creates a record automaticlly from a http context

func (*Record) Expired

func (r *Record) Expired() bool

Expired checkes if a session is out of data

func (*Record) Match

func (r *Record) Match(ctx context.Context) error

Match checkes if the request is received from the expected user TODO

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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