serversession-backend-redis-1.0.2: Storage backend for serversession using Redis.

Safe HaskellNone
LanguageHaskell98

Web.ServerSession.Backend.Redis.Internal

Description

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

Synopsis

Documentation

data RedisStorage sess Source #

Session storage backend using Redis via the hedis package.

Constructors

RedisStorage 

Fields

Instances

RedisSession sess => Storage (RedisStorage sess) Source #

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

type TransactionM (RedisStorage sess) Source # 
type SessionData (RedisStorage sess) Source # 
type SessionData (RedisStorage sess) = sess

data RedisStorageException Source #

An exception thrown by the serversession-backend-redis package.

Constructors

ExpectedTxSuccess (TxResult ())

We expected TxSuccess but got something else.

ExpectedRight Reply

We expected Right from an Either Reply a but got Left.

transaction :: RedisTx (Queued ()) -> Redis () Source #

Run the given Redis transaction and force its result. Throws a RedisStorageException if the result is not TxSuccess.

unwrap :: Redis (Either Reply a) -> Redis a Source #

Unwraps an Either Reply a by throwing an exception if not Right.

rSessionKey :: SessionId sess -> ByteString Source #

Redis key for the given session ID.

rAuthKey :: AuthId -> ByteString Source #

Redis key for the given auth ID.

class IsSessionData sess => RedisSession sess where Source #

Class for data types that can be used as session data for the Redis backend.

It should hold that

fromHash p . perm . toHash p  ===  id

for all list permutations perm :: [a] -> [a], where p :: Proxy sess.

Minimal complete definition

toHash, fromHash

Methods

toHash :: Proxy sess -> Decomposed sess -> [(ByteString, ByteString)] Source #

Transform a decomposed session into a Redis hash. Keys will be prepended with "data:" before being stored.

fromHash :: Proxy sess -> [(ByteString, ByteString)] -> Decomposed sess Source #

Parse back a Redis hash into session data.

Instances

RedisSession SessionMap Source #

Assumes that keys are UTF-8 encoded when parsing (which is true if keys are always generated via toHash).

parseSession :: forall sess. RedisSession sess => SessionId sess -> [(ByteString, ByteString)] -> Maybe (Session sess) Source #

Parse a Session from a Redis hash.

printSession :: forall sess. RedisSession sess => Session sess -> [(ByteString, ByteString)] Source #

Convert a Session into a Redis hash.

parseUTCTime :: ByteString -> UTCTime Source #

Parse UTCTime from a ByteString stored on Redis. Uses error on parse error.

printUTCTime :: UTCTime -> ByteString Source #

Convert a UTCTime into a ByteString to be stored on Redis.

timeFormat :: String Source #

Time format used when storing UTCTime.

getSessionImpl :: RedisSession sess => SessionId sess -> Redis (Maybe (Session sess)) Source #

Get the session for the given session ID.

deleteSessionImpl :: RedisSession sess => SessionId sess -> Redis () Source #

Delete the session with given session ID.

removeSessionFromAuthId :: (RedisCtx m f, Functor m) => SessionId sess -> Maybe AuthId -> m () Source #

Remove the given SessionId from the set of sessions of the given AuthId. Does not do anything if Nothing.

insertSessionForAuthId :: (RedisCtx m f, Functor m) => SessionId sess -> Maybe AuthId -> m () Source #

Insert the given SessionId into the set of sessions of the given AuthId. Does not do anything if Nothing.

deleteAllSessionsOfAuthIdImpl :: AuthId -> Redis () Source #

Delete all sessions of the given auth ID.

insertSessionImpl :: RedisSession sess => RedisStorage sess -> Session sess -> Redis () Source #

Insert a new session.

replaceSessionImpl :: RedisSession sess => RedisStorage sess -> Session sess -> Redis () Source #

Replace the contents of a session.