serversession-backend-acid-state-1.0: 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) Source 
SafeCopy (Decomposed sess) => SafeCopy (ServerSessionAcidState sess) Source

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

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) Source 
AcidContext sess => Method (GetSession sess) Source 
SafeCopy (GetSession sess) Source 
type MethodState (GetSession sess) = ServerSessionAcidState sess Source 
type MethodResult (GetSession sess) = Maybe (Session sess) Source 

data DeleteSession sess Source

Instances

AcidContext sess => UpdateEvent (DeleteSession sess) Source 
AcidContext sess => Method (DeleteSession sess) Source 
SafeCopy (DeleteSession sess) Source 
type MethodState (DeleteSession sess) = ServerSessionAcidState sess Source 
type MethodResult (DeleteSession sess) = () Source 

data InsertSession sess Source

Instances

AcidContext sess => UpdateEvent (InsertSession sess) Source 
AcidContext sess => Method (InsertSession sess) Source 
SafeCopy (Decomposed sess) => SafeCopy (InsertSession sess) Source 
type MethodState (InsertSession sess) = ServerSessionAcidState sess Source 
type MethodResult (InsertSession sess) = () Source 

data ReplaceSession sess Source

Instances

AcidContext sess => UpdateEvent (ReplaceSession sess) Source 
AcidContext sess => Method (ReplaceSession sess) Source 
SafeCopy (Decomposed sess) => SafeCopy (ReplaceSession sess) Source 
type MethodState (ReplaceSession sess) = ServerSessionAcidState sess Source 
type MethodResult (ReplaceSession sess) = () Source 

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) Source

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

type TransactionM (AcidStorage sess) = IO Source 
type SessionData (AcidStorage sess) = sess Source