-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.go
41 lines (38 loc) · 1.22 KB
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package sessionmanager
import "time"
// ISessionManager is the interface for session manager
type ISessionManager interface {
// Get a session by session id
GetSession(sessionId string) (ISession, error)
// Create a new session
CreateSession() (ISession, error)
// Destroy a session
DestroySession(sessionId string) error
// SetDefaultSession sets the default session
SetAsDefaultSession(sessionId string) error
// GetDefaultSession gets the default session
GetDefaultSession() (ISession, error)
// GetAllSessions gets all sessions
GetAllSessions() map[string]ISession
// DestroyAllSessions destroys all sessions
DestroyAllSessions() error
// SetAvoidExpired sets if session manager avoid expired sessions
SetAvoidExpired(avoidExpired bool)
}
// Session is the interface for session
type ISession interface {
// Get a value from session
Get(key string) (interface{}, error)
// Set a value to session
Set(key string, value interface{}) error
// Delete a value from session
Delete(key string) error
// Get session id
SessionId() string
// Set ExpirationTime
SetExpirationTime(expirationTime time.Time)
// IsExpired checks if session is expired
IsExpired() bool
// IsActive checks if session is active
IsActive() bool
}