serversession-backend-acid-state-1.0.2: Storage backend for serversession using acid-state.

Safe HaskellNone
LanguageHaskell98

Web.ServerSession.Backend.Acid.Internal

Description

Internal module exposing the guts of the package. Use at your own risk. No API stability guarantees apply.

Synopsis

Documentation

type SessionIdToSession sess = HashMap (SessionId sess) (Session sess) Source

Map from session IDs to sessions. The most important map, allowing us efficient access to a session given its ID.

type AuthIdToSessionId sess = HashMap AuthId (Set (SessionId sess)) Source

Map from auth IDs to session IDs. Allow us to invalidate all sessions of given user without having to iterate through the whole SessionIdToSession map.

data ServerSessionAcidState sess Source

The current sessions.

Besides the obvious map from session IDs to sessions, we also maintain a map of auth IDs to session IDs. This allow us to quickly invalidate all sessions of a given user.

Instances

AcidContext sess => IsAcidic (ServerSessionAcidState sess) 
SafeCopy (Decomposed sess) => SafeCopy (ServerSessionAcidState sess)

We can't deriveSafeCopy 0 'base ''ServerSessionAcidState due to the required context.

Typeable (* -> *) ServerSessionAcidState 

removeSessionFromAuthId :: SessionId sess -> Maybe AuthId -> AuthIdToSessionId sess -> AuthIdToSessionId sess Source

Remove the given SessionId from the set of the given AuthId on the map. Does not do anything if no AuthId is provided.

insertSessionForAuthId :: SessionId sess -> Maybe AuthId -> AuthIdToSessionId sess -> AuthIdToSessionId sess Source

Insert the given session ID as being part of the given auth ID. Conceptually the opposite of removeSessionFromAuthId. Does not do anything if no AuthId is provided.

getSession :: Storage (AcidStorage sess) => SessionId sess -> Query (ServerSessionAcidState sess) (Maybe (Session sess)) Source

Get the session for the given session ID.

deleteSession :: Storage (AcidStorage sess) => SessionId sess -> Update (ServerSessionAcidState sess) () Source

Delete the session with given session ID.

deleteAllSessionsOfAuthId :: Storage (AcidStorage sess) => AuthId -> Update (ServerSessionAcidState sess) () Source

Delete all sessions of the given auth ID.

insertSession :: Storage (AcidStorage sess) => Session sess -> Update (ServerSessionAcidState sess) () Source

Insert a new session.

replaceSession :: Storage (AcidStorage sess) => Session sess -> Update (ServerSessionAcidState sess) () Source

Replace the contents of a session.

data GetSession sess Source

Instances

AcidContext sess => QueryEvent (GetSession sess) 
AcidContext sess => Method (GetSession sess) 
SafeCopy (GetSession sess) 
Typeable (* -> *) GetSession 
type MethodState (GetSession sess) = ServerSessionAcidState sess 
type MethodResult (GetSession sess) = Maybe (Session sess) 

data DeleteSession sess Source

Instances

AcidContext sess => UpdateEvent (DeleteSession sess) 
AcidContext sess => Method (DeleteSession sess) 
SafeCopy (DeleteSession sess) 
Typeable (* -> *) DeleteSession 
type MethodState (DeleteSession sess) = ServerSessionAcidState sess 
type MethodResult (DeleteSession sess) = () 

data InsertSession sess Source

Instances

AcidContext sess => UpdateEvent (InsertSession sess) 
AcidContext sess => Method (InsertSession sess) 
SafeCopy (Decomposed sess) => SafeCopy (InsertSession sess) 
Typeable (* -> *) InsertSession 
type MethodState (InsertSession sess) = ServerSessionAcidState sess 
type MethodResult (InsertSession sess) = () 

data ReplaceSession sess Source

Instances

AcidContext sess => UpdateEvent (ReplaceSession sess) 
AcidContext sess => Method (ReplaceSession sess) 
SafeCopy (Decomposed sess) => SafeCopy (ReplaceSession sess) 
Typeable (* -> *) ReplaceSession 
type MethodState (ReplaceSession sess) = ServerSessionAcidState sess 
type MethodResult (ReplaceSession sess) = () 

newtype AcidStorage sess Source

Session storage backend using acid-state.

Constructors

AcidStorage 

Fields

acidState :: AcidState (ServerSessionAcidState sess)

Open AcidState of server sessions.

Instances

(IsSessionData sess, SafeCopy sess, SafeCopy (Decomposed sess)) => Storage (AcidStorage sess)

We do not provide any ACID guarantees for different actions running inside the same TransactionM AcidStorage.

Typeable (* -> *) AcidStorage 
type TransactionM (AcidStorage sess) = IO 
type SessionData (AcidStorage sess) = sess