hedis
Safe HaskellNone
LanguageHaskell2010

Database.Redis.Transactions

Synopsis

Documentation

watch Source #

Arguments

:: [ByteString]

key

-> Redis (Either Reply Status) 

Watch the given keys to determine execution of the MULTI/EXEC block (http://redis.io/commands/watch).

multiExec :: RedisTx (Queued a) -> Redis (TxResult a) Source #

Run commands inside a transaction. For documentation on the semantics of Redis transaction see http://redis.io/topics/transactions.

Inside the transaction block, command functions return their result wrapped in a Queued. The Queued result is a proxy object for the actual command's result, which will only be available after EXECing the transaction.

Example usage (note how Queued 's Applicative instance is used to combine the two individual results):

 runRedis conn $ do
     set "hello" "hello"
     set "world" "world"
     helloworld <- multiExec $ do
         hello <- get "hello"
         world <- get "world"
         return $ (,) <$> hello <*> world
     liftIO (print helloworld)
 

data Queued a Source #

A Queued value represents the result of a command inside a transaction. It is a proxy object for the actual result, which will only be available after returning from a multiExec transaction.

Queued values are composable by utilizing the Functor, Applicative or Monad interfaces.

Instances

Instances details
Applicative Queued Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

pure :: a -> Queued a #

(<*>) :: Queued (a -> b) -> Queued a -> Queued b #

liftA2 :: (a -> b -> c) -> Queued a -> Queued b -> Queued c #

(*>) :: Queued a -> Queued b -> Queued b #

(<*) :: Queued a -> Queued b -> Queued a #

Functor Queued Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

fmap :: (a -> b) -> Queued a -> Queued b #

(<$) :: a -> Queued b -> Queued a #

Monad Queued Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

(>>=) :: Queued a -> (a -> Queued b) -> Queued b #

(>>) :: Queued a -> Queued b -> Queued b #

return :: a -> Queued a #

RedisCtx RedisTx Queued Source # 
Instance details

Defined in Database.Redis.Transactions

data TxResult a Source #

Result of a multiExec transaction.

Constructors

TxSuccess a

Transaction completed successfully. The wrapped value corresponds to the Queued value returned from the multiExec argument action.

TxAborted

Transaction aborted due to an earlier watch command.

TxError String

At least one of the commands returned an Error reply.

Instances

Instances details
NFData a => NFData (TxResult a) Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

rnf :: TxResult a -> () #

Generic (TxResult a) Source # 
Instance details

Defined in Database.Redis.Transactions

Associated Types

type Rep (TxResult a) 
Instance details

Defined in Database.Redis.Transactions

type Rep (TxResult a) = D1 ('MetaData "TxResult" "Database.Redis.Transactions" "hedis-0.16.2-inplace" 'False) (C1 ('MetaCons "TxSuccess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: (C1 ('MetaCons "TxAborted" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TxError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))))

Methods

from :: TxResult a -> Rep (TxResult a) x #

to :: Rep (TxResult a) x -> TxResult a #

Show a => Show (TxResult a) Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

showsPrec :: Int -> TxResult a -> ShowS #

show :: TxResult a -> String #

showList :: [TxResult a] -> ShowS #

Eq a => Eq (TxResult a) Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

(==) :: TxResult a -> TxResult a -> Bool #

(/=) :: TxResult a -> TxResult a -> Bool #

type Rep (TxResult a) Source # 
Instance details

Defined in Database.Redis.Transactions

type Rep (TxResult a) = D1 ('MetaData "TxResult" "Database.Redis.Transactions" "hedis-0.16.2-inplace" 'False) (C1 ('MetaCons "TxSuccess" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)) :+: (C1 ('MetaCons "TxAborted" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "TxError" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))))

data RedisTx a Source #

Command-context inside of MULTI/EXEC transactions. Use multiExec to run actions of this type.

In the RedisTx context, all commands return a Queued value. It is a proxy object for the actual result, which will only be available after finishing the transaction.

Instances

Instances details
MonadIO RedisTx Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

liftIO :: IO a -> RedisTx a #

Applicative RedisTx Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

pure :: a -> RedisTx a #

(<*>) :: RedisTx (a -> b) -> RedisTx a -> RedisTx b #

liftA2 :: (a -> b -> c) -> RedisTx a -> RedisTx b -> RedisTx c #

(*>) :: RedisTx a -> RedisTx b -> RedisTx b #

(<*) :: RedisTx a -> RedisTx b -> RedisTx a #

Functor RedisTx Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

fmap :: (a -> b) -> RedisTx a -> RedisTx b #

(<$) :: a -> RedisTx b -> RedisTx a #

Monad RedisTx Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

(>>=) :: RedisTx a -> (a -> RedisTx b) -> RedisTx b #

(>>) :: RedisTx a -> RedisTx b -> RedisTx b #

return :: a -> RedisTx a #

MonadRedis RedisTx Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

liftRedis :: Redis a -> RedisTx a Source #

RedisCtx RedisTx Queued Source # 
Instance details

Defined in Database.Redis.Transactions