state

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package state contains the go implementation for storing and loading the Session from the cache.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is the struct that contains the connection info for retrieving/saving The session data.

func NewCache

func NewCache(addr string, db int, password string) *Cache

NewCache will properly initialise a new Cache object.

type Connection

type Connection interface {
	Set(key string, value interface{}, expiration time.Duration) *redis.StatusCmd
	Get(key string) *redis.StringCmd
	Del(key ...string) *redis.IntCmd
}

Connection is the interface used to interact with the Redis database

type Store

type Store struct {
	ID      string
	Expires uint64
	Data    session.Session
	// contains filtered or unexported fields
}

Store is the struct that is used to load/store the session.

func NewStore

func NewStore(cache *Cache) *Store

NewStore will properly initialise a new Store object.

func (*Store) Clear

func (s *Store) Clear() error

Clear destroys the current loaded session and removes it from the backing store. It will also regenerate the session ID.

func (*Store) Delete

func (s *Store) Delete(id *string) error

Delete will clear the requested session from the backing store. Note: Delete does not clear the loaded session. The Clear method will take care of that. If the string passed in is nil, it will delete the session with an id the same as that of s.ID

func (*Store) GenerateSignature

func (s *Store) GenerateSignature() string

GenerateSignature will generate a new signature based on the Store ID and the cookie secret.

func (*Store) Load

func (s *Store) Load(sessionID string) error

Load is used to try and get a session from the cache. If it succeeds it will load the session, otherwise it will return an error.

func (*Store) Store

func (s *Store) Store() error

Store operates on a Store struct, saving it in the cache. Firstly, if the session data is nil, it will be set to an empty map. If the ID is not supplied, one will be generated. If expiry is its default value (0), it will be set on the store. The session will then be encoded, and an attempt made to save it.

Directories

Path Synopsis
Code generated by mockery v1.0.0 DO NOT EDIT.
Code generated by mockery v1.0.0 DO NOT EDIT.

Jump to

Keyboard shortcuts

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