Initial Codebase (untested)

This commit is contained in:
James Mills
2021-01-30 14:05:04 +10:00
parent c1dc91b7e0
commit 4529ea3196
60 changed files with 9807 additions and 0 deletions

32
internal/session/store.go Normal file
View File

@@ -0,0 +1,32 @@
package session
import (
"errors"
"time"
)
// DefaultSessionDuration is the default duration for
// saving session data in the store. Most Store implementations
// will automatically delete saved session data after this time.
const DefaultSessionDuration = time.Hour
var (
ErrSessionNotFound = errors.New("sessin not found or expired")
ErrSessionExpired = errors.New("session expired")
)
// Store represents a session data store.
// This is an abstract interface that can be implemented
// against several different types of data stores. For example,
// session data could be stored in memory in a concurrent map,
// or more typically in a shared key/value server store like redis.
type Store interface {
GetSession(sid string) (*Session, error)
SetSession(sid string, sess *Session) error
HasSession(sid string) bool
DelSession(sid string) error
SyncSession(sess *Session) error
GetAllSessions() ([]*Session, error)
}