dvsession

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionId                         = "SESSION_ID"
	MODE_SESSION_MAY_BE               = 0
	MODE_SESSION_CREATE_IF_NOT_EXISTS = 1
	MODE_SESSION_MUST_EXIST           = 2
)
View Source
const (
	SESSION_ENGINE_FATAL_IMPORTANCE = iota
	SESSION_ENGINE_NON_IMPORTANCE
	SESSION_ENGINE_CAN_BE_MEMORY
	SESSION_ENGINE_CAN_BE_MEMORY_OR_NONE
)
View Source
const DefaultRetentionTime = 3600 * 3
View Source
const MEMORY_SESSION_ENGINE = "MEMORY"
View Source
const SESSION_RETENTION_TIME = "RETENTION_TIME"

Variables

This section is empty.

Functions

func CleanOldSessions

func CleanOldSessions(updateTime int64) (err error)

func CreateSession

func CreateSession(initialData map[string]string, env *dvevaluation.DvObject) (err error)

func GetRetentionTime

func GetRetentionTime(params map[string]string) int

func GetServerSessionProvider

func GetServerSessionProvider(name string, option int, params map[string]string, urls map[string]string, prefix string) dvcontext.ServerSessionProvider

func GetStorageSession

func GetStorageSession(context *dvgrammar.ExpressionContext) (dvcontext.RequestSession, error)

func GlobalMapDelete

func GlobalMapDelete(mapName string, key string) bool

func GlobalMapRead

func GlobalMapRead(mapName string, key string) (interface{}, bool)

func GlobalMapWrite

func GlobalMapWrite(mapName string, key string, val interface{})

func IsSessionPresent

func IsSessionPresent(sessionId string) (bool, error)

func ReadSession

func ReadSession(sessionId string, force bool) (data map[string]string, err error)

func ReadSessionByEnvironment

func ReadSessionByEnvironment(env *dvevaluation.DvObject) (string, map[string]string, error)

func RegisterSessionEngine

func RegisterSessionEngine(name string, engine SessionEngine) bool

func UpdateBySession

func UpdateBySession(env *dvevaluation.DvObject, mode int) (err error)

func UpdateSessionWithKeyValue

func UpdateSessionWithKeyValue(env *dvevaluation.DvObject, key string, value string) (err error)

func UpdateSessionWithMap

func UpdateSessionWithMap(env *dvevaluation.DvObject, info map[string]string) (err error)

func WriteToSession

func WriteToSession(sessionId string, data map[string]string) (orig map[string]string, err error)

Types

type MemorySessionEngine

type MemorySessionEngine struct {
}

func (*MemorySessionEngine) Close

func (engine *MemorySessionEngine) Close()

func (*MemorySessionEngine) Init

func (engine *MemorySessionEngine) Init(params map[string]string) (SessionRequest, error)

type MemorySessionRequest

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

func (*MemorySessionRequest) CollectGarbage

func (req *MemorySessionRequest) CollectGarbage()

func (*MemorySessionRequest) Init

func (req *MemorySessionRequest) Init(id string, createOnly bool, updateOnly bool) (SessionStorage, error, bool)

type MemorySessionStorage

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

func (*MemorySessionStorage) Clear

func (storage *MemorySessionStorage) Clear()

func (*MemorySessionStorage) GetId

func (storage *MemorySessionStorage) GetId() string

func (*MemorySessionStorage) GetItem

func (storage *MemorySessionStorage) GetItem(key string) interface{}

func (*MemorySessionStorage) Keys

func (storage *MemorySessionStorage) Keys() []string

func (*MemorySessionStorage) RemoveItem

func (storage *MemorySessionStorage) RemoveItem(key string)

func (*MemorySessionStorage) SetItem

func (storage *MemorySessionStorage) SetItem(key string, value interface{})

func (*MemorySessionStorage) UpdateAccessTime

func (storage *MemorySessionStorage) UpdateAccessTime()

func (*MemorySessionStorage) Values

func (storage *MemorySessionStorage) Values() map[string]interface{}

type SessionActionBlock

type SessionActionBlock struct {
	Prefix  string
	Id      string
	Storage SessionStorage
}

func (*SessionActionBlock) Clear

func (block *SessionActionBlock) Clear()

func (*SessionActionBlock) GetId

func (block *SessionActionBlock) GetId() string

func (*SessionActionBlock) GetItem

func (block *SessionActionBlock) GetItem(key string) interface{}

func (*SessionActionBlock) Keys

func (block *SessionActionBlock) Keys() []string

func (*SessionActionBlock) RemoveItem

func (block *SessionActionBlock) RemoveItem(key string)

func (*SessionActionBlock) SetItem

func (block *SessionActionBlock) SetItem(key string, value interface{})

func (*SessionActionBlock) SetSessionVariables

func (block *SessionActionBlock) SetSessionVariables(ctx *dvcontext.RequestContext, isLoad bool, pref string)

func (*SessionActionBlock) Values

func (block *SessionActionBlock) Values() map[string]interface{}

type SessionEngine

type SessionEngine interface {
	Init(map[string]string) (SessionRequest, error)
	Close()
}

func GetSessionEngine

func GetSessionEngine(name string, option int) SessionEngine

type SessionMetaInfo

type SessionMetaInfo struct {
	Db              string   `json:"db"`
	Table           string   `json:"table"`
	Id              string   `json:"id"`
	Data            string   `json:"data"`
	ModTime         string   `json:"modTime"`
	Prefix          string   `json:"prefix"`
	ReadSql         []string `json:"readSql"`
	CreateSql       []string `json:"createSql"`
	UpdateSql       []string `json:"updateSql"`
	DeleteExpireSql string   `json:"deleteExpireSql"`
	SqlType         int
	// contains filtered or unexported fields
}

type SessionRequest

type SessionRequest interface {
	Init(id string, createOnly bool, updateOnly bool) (SessionStorage, error, bool)
}

func GetSessionRequest

func GetSessionRequest(name string, params map[string]string, option int) SessionRequest

type SessionRequestBlock

type SessionRequestBlock struct {
	Prefix  string
	Request SessionRequest
	Urls    *dvurl.UrlPool
}

func (*SessionRequestBlock) GetSessionStorage

func (action *SessionRequestBlock) GetSessionStorage(ctx *dvcontext.RequestContext, request *dvcontext.SessionActionRequest, sessionId string) (dvcontext.RequestSession, error)

type SessionStorage

type SessionStorage interface {
	SetItem(key string, value interface{})
	GetItem(key string) interface{}
	RemoveItem(key string)
	Clear()
	Keys() []string
	Values() map[string]interface{}
}

Jump to

Keyboard shortcuts

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