rsm

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2023 License: MIT Imports: 8 Imported by: 1

README

RSM: Redis based Session Manager

Documentation

Index

Constants

View Source
const (
	ErrSessionNotFound  = managerError("session not found")
	ErrPropertyNotFound = managerError("property not found")
	ErrEmptyToken       = managerError("the provided token is empty")
	ErrEmptyValueKey    = managerError("the provided value key is empty")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type SessionManager

type SessionManager struct {
	Store       Store
	Lifetime    time.Duration
	TokenLength uint
}

func New

func New(pool *redis.Pool) *SessionManager

func (*SessionManager) DeleteValue

func (sm *SessionManager) DeleteValue(token, key string) error

func (*SessionManager) DestroySession

func (sm *SessionManager) DestroySession(token string) error

func (*SessionManager) GetValue

func (sm *SessionManager) GetValue(token, key string) (any, error)

func (*SessionManager) InitSession

func (sm *SessionManager) InitSession() (string, error)

func (*SessionManager) RenewToken

func (sm *SessionManager) RenewToken(token string) (newToken string, err error)

func (*SessionManager) RetrieveSession

func (sm *SessionManager) RetrieveSession(token string) (map[string]any, time.Time, error)

func (*SessionManager) SetValue

func (sm *SessionManager) SetValue(token, key string, v any) error

type Store

type Store interface {
	Retrieve(token string) (data []byte, err error)
	Insert(token string, data []byte, expiry time.Time) error
	Delete(token string) error
}

Jump to

Keyboard shortcuts

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