-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Storage backend for serversession using Redis.
--   
--   API docs and the README are available at
--   <a>http://www.stackage.org/package/serversession-backend-redis</a>
@package serversession-backend-redis
@version 1.0.3


-- | Internal module exposing the guts of the package. Use at your own
--   risk. No API stability guarantees apply.
module Web.ServerSession.Backend.Redis.Internal

-- | Session storage backend using Redis via the <tt>hedis</tt> package.
data RedisStorage sess
RedisStorage :: Connection -> Maybe NominalDiffTime -> Maybe NominalDiffTime -> RedisStorage sess

-- | Connection pool to the Redis server.
[connPool] :: RedisStorage sess -> Connection

-- | How long should a session live after last access
[idleTimeout] :: RedisStorage sess -> Maybe NominalDiffTime

-- | How long should a session live after creation
[absoluteTimeout] :: RedisStorage sess -> Maybe NominalDiffTime

-- | An exception thrown by the <tt>serversession-backend-redis</tt>
--   package.
data RedisStorageException

-- | We expected <tt>TxSuccess</tt> but got something else.
ExpectedTxSuccess :: (TxResult ()) -> RedisStorageException

-- | We expected <a>Right</a> from an <tt>Either <a>Reply</a> a</tt> but
--   got <a>Left</a>.
ExpectedRight :: Reply -> RedisStorageException

-- | Run the given Redis transaction and force its result. Throws a
--   <a>RedisStorageException</a> if the result is not <tt>TxSuccess</tt>.
transaction :: RedisTx (Queued ()) -> Redis ()

-- | Unwraps an <tt>Either <a>Reply</a> a</tt> by throwing an exception if
--   not <tt>Right</tt>.
unwrap :: Redis (Either Reply a) -> Redis a

-- | Redis key for the given session ID.
rSessionKey :: SessionId sess -> ByteString

-- | Redis key for the given auth ID.
rAuthKey :: AuthId -> ByteString

-- | Class for data types that can be used as session data for the Redis
--   backend.
--   
--   It should hold that
--   
--   <pre>
--   fromHash p . perm . toHash p  ===  id
--   </pre>
--   
--   for all list permutations <tt>perm :: [a] -&gt; [a]</tt>, where <tt>p
--   :: Proxy sess</tt>.
class IsSessionData sess => RedisSession sess

-- | Transform a decomposed session into a Redis hash. Keys will be
--   prepended with <tt>"data:"</tt> before being stored.
toHash :: RedisSession sess => Proxy sess -> Decomposed sess -> [(ByteString, ByteString)]

-- | Parse back a Redis hash into session data.
fromHash :: RedisSession sess => Proxy sess -> [(ByteString, ByteString)] -> Decomposed sess

-- | Parse a <a>Session</a> from a Redis hash.
parseSession :: forall sess. RedisSession sess => SessionId sess -> [(ByteString, ByteString)] -> Maybe (Session sess)

-- | Convert a <a>Session</a> into a Redis hash.
printSession :: forall sess. RedisSession sess => Session sess -> [(ByteString, ByteString)]

-- | Parse <tt>UTCTime</tt> from a <a>ByteString</a> stored on Redis. Uses
--   <a>error</a> on parse error.
parseUTCTime :: ByteString -> UTCTime

-- | Convert a <tt>UTCTime</tt> into a <a>ByteString</a> to be stored on
--   Redis.
printUTCTime :: UTCTime -> ByteString

-- | Time format used when storing <tt>UTCTime</tt>.
timeFormat :: String

-- | Get the session for the given session ID.
getSessionImpl :: RedisSession sess => SessionId sess -> Redis (Maybe (Session sess))

-- | Delete the session with given session ID.
deleteSessionImpl :: RedisSession sess => SessionId sess -> Redis ()

-- | Remove the given <a>SessionId</a> from the set of sessions of the
--   given <a>AuthId</a>. Does not do anything if <tt>Nothing</tt>.
removeSessionFromAuthId :: (RedisCtx m f, Functor m) => SessionId sess -> Maybe AuthId -> m ()

-- | Insert the given <a>SessionId</a> into the set of sessions of the
--   given <a>AuthId</a>. Does not do anything if <tt>Nothing</tt>.
insertSessionForAuthId :: (RedisCtx m f, Functor m) => SessionId sess -> Maybe AuthId -> m ()

-- | Delete all sessions of the given auth ID.
deleteAllSessionsOfAuthIdImpl :: AuthId -> Redis ()

-- | Insert a new session.
insertSessionImpl :: RedisSession sess => RedisStorage sess -> Session sess -> Redis ()

-- | Replace the contents of a session.
replaceSessionImpl :: RedisSession sess => RedisStorage sess -> Session sess -> Redis ()

-- | Specialization of <a>throwIO</a> for <a>RedisStorage</a>.
throwRS :: Storage (RedisStorage sess) => StorageException (RedisStorage sess) -> Redis a
instance GHC.Show.Show Web.ServerSession.Backend.Redis.Internal.RedisStorageException
instance Web.ServerSession.Backend.Redis.Internal.RedisSession sess => Web.ServerSession.Core.Internal.Storage (Web.ServerSession.Backend.Redis.Internal.RedisStorage sess)
instance Web.ServerSession.Backend.Redis.Internal.RedisSession Web.ServerSession.Core.Internal.SessionMap
instance GHC.Exception.Exception Web.ServerSession.Backend.Redis.Internal.RedisStorageException


-- | Storage backend for <tt>serversession</tt> using Redis via
--   <tt>hedis</tt>.
module Web.ServerSession.Backend.Redis

-- | Session storage backend using Redis via the <tt>hedis</tt> package.
data RedisStorage sess
RedisStorage :: Connection -> Maybe NominalDiffTime -> Maybe NominalDiffTime -> RedisStorage sess

-- | Connection pool to the Redis server.
[connPool] :: RedisStorage sess -> Connection

-- | How long should a session live after last access
[idleTimeout] :: RedisStorage sess -> Maybe NominalDiffTime

-- | How long should a session live after creation
[absoluteTimeout] :: RedisStorage sess -> Maybe NominalDiffTime

-- | An exception thrown by the <tt>serversession-backend-redis</tt>
--   package.
data RedisStorageException

-- | We expected <tt>TxSuccess</tt> but got something else.
ExpectedTxSuccess :: (TxResult ()) -> RedisStorageException

-- | We expected <a>Right</a> from an <tt>Either <a>Reply</a> a</tt> but
--   got <a>Left</a>.
ExpectedRight :: Reply -> RedisStorageException

-- | Class for data types that can be used as session data for the Redis
--   backend.
--   
--   It should hold that
--   
--   <pre>
--   fromHash p . perm . toHash p  ===  id
--   </pre>
--   
--   for all list permutations <tt>perm :: [a] -&gt; [a]</tt>, where <tt>p
--   :: Proxy sess</tt>.
class IsSessionData sess => RedisSession sess

-- | Transform a decomposed session into a Redis hash. Keys will be
--   prepended with <tt>"data:"</tt> before being stored.
toHash :: RedisSession sess => Proxy sess -> Decomposed sess -> [(ByteString, ByteString)]

-- | Parse back a Redis hash into session data.
fromHash :: RedisSession sess => Proxy sess -> [(ByteString, ByteString)] -> Decomposed sess
