session

package
v0.0.0-...-ada05ea Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2013 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SessionNotExists = errors.New("session id doesn't exists")
)

Functions

func NewId

func NewId() string

return sesstion id

func Register

func Register(name string, driver Driver)

Register register a session driver by the provided name

Types

type Driver

type Driver interface {
	// Initialize setup this driver
	Init(options string) error

	// return name of this driver
	Name() string

	// Get return item value of session marked with sessionId, return false if key exists
	Add(sessionId, key string, value interface{}) (bool, error)

	// Get return item value of session marked with sessionId, return false if key doesn't exists
	Get(sessionId, key string) (interface{}, bool, error)

	// Set add or update a item
	Set(sessionId, key string, value interface{}) error

	// Remove remove item from session
	Remove(sessionId, key string) error

	// New create a new session entry
	New(sessionId string, timeout time.Duration) error

	// Abandon mark session abandon
	Abandon(sessionId string) error

	// Exists return false if sessionId doesn't exists
	Exists(sessionId string) (bool, error)

	// Keys all item keys of session
	Keys(sessionId string) ([]string, error)
}

func GetDriver

func GetDriver(name string) Driver

type MCache

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

func (*MCache) Abandon

func (mc *MCache) Abandon(sessionId string) error

func (*MCache) Add

func (mc *MCache) Add(sessionId, key string, value interface{}) (bool, error)

func (*MCache) Exists

func (mc *MCache) Exists(sessionId string) (bool, error)

func (*MCache) Get

func (mc *MCache) Get(sessionId, key string) (interface{}, bool, error)

func (*MCache) Init

func (mc *MCache) Init(options string) error

func (*MCache) Keys

func (mc *MCache) Keys(sessionId string) ([]string, error)

func (*MCache) Name

func (mc *MCache) Name() string

func (*MCache) New

func (mc *MCache) New(sessionId string, timeout time.Duration) error

func (*MCache) Remove

func (mc *MCache) Remove(sessionId, key string) error

func (*MCache) Set

func (mc *MCache) Set(sessionId, key string, value interface{}) error

type Session

type Session struct {
	CreateAt time.Time
	Id       string
}

Jump to

Keyboard shortcuts

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