sessions

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionNotFound = errors.New("Session not found")
)

Functions

This section is empty.

Types

type MemorySessionManager

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

func NewMemorySessionManager

func NewMemorySessionManager() *MemorySessionManager

NewMemorySessionManager - Create a new MemorySessionManager object

func (*MemorySessionManager) Add

func (sm *MemorySessionManager) Add(session *Session)

func (*MemorySessionManager) Clean

func (sm *MemorySessionManager) Clean()

func (*MemorySessionManager) CreateSession

func (sm *MemorySessionManager) CreateSession(userName string, isAdmin bool) (*Session, bool)

func (*MemorySessionManager) Exists

func (sm *MemorySessionManager) Exists(key string) bool

func (*MemorySessionManager) FromBinary

func (sm *MemorySessionManager) FromBinary(data []byte) *Session

func (*MemorySessionManager) Get

func (sm *MemorySessionManager) Get(key string) (*Session, error)

func (*MemorySessionManager) GetSessionCount

func (sm *MemorySessionManager) GetSessionCount() int

func (*MemorySessionManager) Remove

func (sm *MemorySessionManager) Remove(key string)

func (*MemorySessionManager) ToBinary

func (sm *MemorySessionManager) ToBinary(session *Session) []byte

type RedisSessionManager

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

func NewRedisSessionManager

func NewRedisSessionManager(client *redis.Client) *RedisSessionManager

func (*RedisSessionManager) Add

func (sm *RedisSessionManager) Add(session *Session)

func (*RedisSessionManager) Clean

func (sm *RedisSessionManager) Clean()

func (*RedisSessionManager) CreateSession

func (sm *RedisSessionManager) CreateSession(userName string, isAdmin bool) (*Session, bool)

func (*RedisSessionManager) Exists

func (sm *RedisSessionManager) Exists(key string) bool

func (*RedisSessionManager) FromBinary

func (sm *RedisSessionManager) FromBinary(data []byte) *Session

func (*RedisSessionManager) Get

func (sm *RedisSessionManager) Get(key string) (*Session, error)

func (*RedisSessionManager) GetSessionCount

func (sm *RedisSessionManager) GetSessionCount() int

func (*RedisSessionManager) Remove

func (sm *RedisSessionManager) Remove(key string)

func (*RedisSessionManager) ToBinary

func (sm *RedisSessionManager) ToBinary(session *Session) []byte

type Session

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

func (*Session) GetData

func (s *Session) GetData(key string) interface{}

func (*Session) GetID

func (s *Session) GetID() string

func (*Session) GetUserName

func (s *Session) GetUserName() string

func (*Session) IsAdmin

func (s *Session) IsAdmin() bool

func (*Session) IsLogin

func (s *Session) IsLogin() bool

func (*Session) SetAdmin

func (s *Session) SetAdmin(isAdmin bool)

func (*Session) SetData

func (s *Session) SetData(key string, value interface{})

func (*Session) SetLogin

func (s *Session) SetLogin(isLogin bool)

func (*Session) SetUserName

func (s *Session) SetUserName(userName string)

func (*Session) UpdateLastSeen

func (s *Session) UpdateLastSeen()

type SessionManager

type SessionManager interface {
	CreateSession(userName string, isAdmin bool) (*Session, bool)
	Get(key string) (*Session, error)
	GetSessionCount() int
	Clean()
	Add(session *Session)
	Remove(key string)
	Exists(key string) bool
	FromBinary(data []byte) *Session
	ToBinary(session *Session) []byte
}

Jump to

Keyboard shortcuts

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