hedis-0.15.0: Client library for the Redis datastore: supports full command set, pipelining.
Safe HaskellNone
LanguageHaskell2010

Database.Redis.Sentinel

Description

Database.Redis like interface with connection through Redis Sentinel.

More details here: https://redis.io/topics/sentinel.

Example:

conn <- connect SentinelConnectionInfo (("localhost", PortNumber 26379) :| []) "mymaster" defaultConnectInfo

runRedis conn $ do
  set "hello" "world"

When connection is opened, the Sentinels will be queried to get current master. Subsequent runRedis calls will talk to that master.

If runRedis call fails, the next call will choose a new master to talk to.

This implementation is based on Gist by Emanuel Borsboom at https://gist.github.com/borsboom/681d37d273d5c4168723

Synopsis

Connection

data SentinelConnectInfo Source #

Configuration of Sentinel hosts.

Constructors

SentinelConnectInfo 

Fields

runRedis with Sentinel support

runRedis :: SentinelConnection -> Redis (Either Reply a) -> IO (Either Reply a) Source #

Interact with a Redis datastore. See runRedis for details.

Re-export Database.Redis

data HashSlot Source #

Instances

Instances details
Enum HashSlot Source # 
Instance details

Defined in Database.Redis.Cluster.HashSlot

Eq HashSlot Source # 
Instance details

Defined in Database.Redis.Cluster.HashSlot

Integral HashSlot Source # 
Instance details

Defined in Database.Redis.Cluster.HashSlot

Num HashSlot Source # 
Instance details

Defined in Database.Redis.Cluster.HashSlot

Ord HashSlot Source # 
Instance details

Defined in Database.Redis.Cluster.HashSlot

Real HashSlot Source # 
Instance details

Defined in Database.Redis.Cluster.HashSlot

Show HashSlot Source # 
Instance details

Defined in Database.Redis.Cluster.HashSlot

keyToSlot :: ByteString -> HashSlot Source #

Compute the hashslot associated with a key

data PortID Source #

Instances

Instances details
Eq PortID Source # 
Instance details

Defined in Database.Redis.ConnectionContext

Methods

(==) :: PortID -> PortID -> Bool #

(/=) :: PortID -> PortID -> Bool #

Show PortID Source # 
Instance details

Defined in Database.Redis.ConnectionContext

data Reply Source #

Low-level representation of replies from the Redis server.

Instances

Instances details
Eq Reply Source # 
Instance details

Defined in Database.Redis.Protocol

Methods

(==) :: Reply -> Reply -> Bool #

(/=) :: Reply -> Reply -> Bool #

Show Reply Source # 
Instance details

Defined in Database.Redis.Protocol

Methods

showsPrec :: Int -> Reply -> ShowS #

show :: Reply -> String #

showList :: [Reply] -> ShowS #

Generic Reply Source # 
Instance details

Defined in Database.Redis.Protocol

Associated Types

type Rep Reply :: Type -> Type #

Methods

from :: Reply -> Rep Reply x #

to :: Rep Reply x -> Reply #

NFData Reply Source # 
Instance details

Defined in Database.Redis.Protocol

Methods

rnf :: Reply -> () #

RedisResult Reply Source # 
Instance details

Defined in Database.Redis.Types

RedisCtx Redis (Either Reply) Source # 
Instance details

Defined in Database.Redis.Core

type Rep Reply Source # 
Instance details

Defined in Database.Redis.Protocol

data RedisType Source #

Constructors

None 
String 
Hash 
List 
Set 
ZSet 

Instances

Instances details
Eq RedisType Source # 
Instance details

Defined in Database.Redis.Types

Show RedisType Source # 
Instance details

Defined in Database.Redis.Types

RedisResult RedisType Source # 
Instance details

Defined in Database.Redis.Types

data Status Source #

Constructors

Ok 
Pong 
Status ByteString 

Instances

Instances details
Eq Status Source # 
Instance details

Defined in Database.Redis.Types

Methods

(==) :: Status -> Status -> Bool #

(/=) :: Status -> Status -> Bool #

Show Status Source # 
Instance details

Defined in Database.Redis.Types

Generic Status Source # 
Instance details

Defined in Database.Redis.Types

Associated Types

type Rep Status :: Type -> Type #

Methods

from :: Status -> Rep Status x #

to :: Rep Status x -> Status #

NFData Status Source # 
Instance details

Defined in Database.Redis.Types

Methods

rnf :: Status -> () #

RedisResult Status Source # 
Instance details

Defined in Database.Redis.Types

type Rep Status Source # 
Instance details

Defined in Database.Redis.Types

type Rep Status = D1 ('MetaData "Status" "Database.Redis.Types" "hedis-0.15.0-GCMFyxECy1BFDoCfBfdCzo" 'False) (C1 ('MetaCons "Ok" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Pong" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Status" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))))

class RedisResult a where Source #

Methods

decode :: Reply -> Either Reply a Source #

Instances

Instances details
RedisResult Bool Source # 
Instance details

Defined in Database.Redis.Types

RedisResult Double Source # 
Instance details

Defined in Database.Redis.Types

RedisResult Integer Source # 
Instance details

Defined in Database.Redis.Types

RedisResult ByteString Source # 
Instance details

Defined in Database.Redis.Types

RedisResult Reply Source # 
Instance details

Defined in Database.Redis.Types

RedisResult RedisType Source # 
Instance details

Defined in Database.Redis.Types

RedisResult Status Source # 
Instance details

Defined in Database.Redis.Types

RedisResult ClusterSlotsResponseEntry Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult ClusterSlotsNode Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult ClusterSlotsResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult ClusterNodesResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult XInfoStreamResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult XInfoGroupsResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult XInfoConsumersResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult XPendingDetailRecord Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult XPendingSummaryResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult XReadResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult StreamsRecord Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult Cursor Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult Slowlog Source # 
Instance details

Defined in Database.Redis.ManualCommands

(RedisResult k, RedisResult v) => RedisResult [(k, v)] Source # 
Instance details

Defined in Database.Redis.Types

Methods

decode :: Reply -> Either Reply [(k, v)] Source #

RedisResult a => RedisResult [a] Source # 
Instance details

Defined in Database.Redis.Types

Methods

decode :: Reply -> Either Reply [a] Source #

RedisResult a => RedisResult (Maybe a) Source # 
Instance details

Defined in Database.Redis.Types

Methods

decode :: Reply -> Either Reply (Maybe a) Source #

(RedisResult a, RedisResult b) => RedisResult (a, b) Source # 
Instance details

Defined in Database.Redis.Types

Methods

decode :: Reply -> Either Reply (a, b) Source #

data Redis a Source #

Context for normal command execution, outside of transactions. Use runRedis to run actions of this type.

In this context, each result is wrapped in an Either to account for the possibility of Redis returning an Error reply.

Instances

Instances details
Monad Redis Source # 
Instance details

Defined in Database.Redis.Core.Internal

Methods

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

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

return :: a -> Redis a #

Functor Redis Source # 
Instance details

Defined in Database.Redis.Core.Internal

Methods

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

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

MonadFail Redis Source # 
Instance details

Defined in Database.Redis.Core.Internal

Methods

fail :: String -> Redis a #

Applicative Redis Source # 
Instance details

Defined in Database.Redis.Core.Internal

Methods

pure :: a -> Redis a #

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

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

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

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

MonadIO Redis Source # 
Instance details

Defined in Database.Redis.Core.Internal

Methods

liftIO :: IO a -> Redis a #

MonadRedis Redis Source # 
Instance details

Defined in Database.Redis.Core

Methods

liftRedis :: Redis a -> Redis a Source #

RedisCtx Redis (Either Reply) Source # 
Instance details

Defined in Database.Redis.Core

class Monad m => MonadRedis m where Source #

Methods

liftRedis :: Redis a -> m a Source #

Instances

Instances details
MonadRedis Redis Source # 
Instance details

Defined in Database.Redis.Core

Methods

liftRedis :: Redis a -> Redis a Source #

MonadRedis RedisTx Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

liftRedis :: Redis a -> RedisTx a Source #

class MonadRedis m => RedisCtx m f | m -> f where Source #

This class captures the following behaviour: In a context m, a command will return its result wrapped in a "container" of type f.

Please refer to the Command Type Signatures section of this page for more information.

Methods

returnDecode :: RedisResult a => Reply -> m (f a) Source #

Instances

Instances details
RedisCtx RedisTx Queued Source # 
Instance details

Defined in Database.Redis.Transactions

RedisCtx Redis (Either Reply) Source # 
Instance details

Defined in Database.Redis.Core

unRedis :: Redis a -> ReaderT RedisEnv IO a Source #

Deconstruct Redis constructor.

unRedis and reRedis can be used to define instances for arbitrary typeclasses.

WARNING! These functions are considered internal and no guarantee is given at this point that they will not break in future.

reRedis :: ReaderT RedisEnv IO a -> Redis a Source #

Reconstruct Redis constructor.

sendRequest :: (RedisCtx m f, RedisResult a) => [ByteString] -> m (f a) Source #

sendRequest can be used to implement commands from experimental versions of Redis. An example of how to implement a command is given below.

-- |Redis DEBUG OBJECT command
debugObject :: ByteString -> Redis (Either Reply ByteString)
debugObject key = sendRequest ["DEBUG", "OBJECT", key]

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
Eq a => Eq (TxResult a) Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

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

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

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 #

Generic (TxResult a) Source # 
Instance details

Defined in Database.Redis.Transactions

Associated Types

type Rep (TxResult a) :: Type -> Type #

Methods

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

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

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

Defined in Database.Redis.Transactions

Methods

rnf :: TxResult a -> () #

type Rep (TxResult a) Source # 
Instance details

Defined in Database.Redis.Transactions

type Rep (TxResult a) = D1 ('MetaData "TxResult" "Database.Redis.Transactions" "hedis-0.15.0-GCMFyxECy1BFDoCfBfdCzo" '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 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
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 #

Functor Queued Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

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

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

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 #

RedisCtx RedisTx Queued Source # 
Instance details

Defined in Database.Redis.Transactions

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
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 #

Functor RedisTx Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

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

(<$) :: a -> RedisTx b -> 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 #

MonadIO RedisTx Source # 
Instance details

Defined in Database.Redis.Transactions

Methods

liftIO :: IO 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

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 XReadOpts Source #

Constructors

XReadOpts 

Instances

Instances details
Eq XReadOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

Show XReadOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

data RangeLex a Source #

Constructors

Incl a 
Excl a 
Minr 
Maxr 

data ScanOpts Source #

Instances

Instances details
Eq ScanOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

Show ScanOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

data Cursor Source #

Instances

Instances details
Eq Cursor Source # 
Instance details

Defined in Database.Redis.ManualCommands

Methods

(==) :: Cursor -> Cursor -> Bool #

(/=) :: Cursor -> Cursor -> Bool #

Show Cursor Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult Cursor Source # 
Instance details

Defined in Database.Redis.ManualCommands

data ReplyMode Source #

Instances

Instances details
Eq ReplyMode Source # 
Instance details

Defined in Database.Redis.ManualCommands

Show ReplyMode Source # 
Instance details

Defined in Database.Redis.ManualCommands

data ZaddOpts Source #

Instances

Instances details
Eq ZaddOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

Show ZaddOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

data DebugMode Source #

Instances

Instances details
Eq DebugMode Source # 
Instance details

Defined in Database.Redis.ManualCommands

Show DebugMode Source # 
Instance details

Defined in Database.Redis.ManualCommands

data SetOpts Source #

Instances

Instances details
Eq SetOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

Methods

(==) :: SetOpts -> SetOpts -> Bool #

(/=) :: SetOpts -> SetOpts -> Bool #

Show SetOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

data Condition Source #

Constructors

Nx 
Xx 

Instances

Instances details
Eq Condition Source # 
Instance details

Defined in Database.Redis.ManualCommands

Show Condition Source # 
Instance details

Defined in Database.Redis.ManualCommands

data MigrateOpts Source #

Options for the migrate command.

Constructors

MigrateOpts 

Instances

Instances details
Eq MigrateOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

Show MigrateOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

data Aggregate Source #

Constructors

Sum 
Min 
Max 

Instances

Instances details
Eq Aggregate Source # 
Instance details

Defined in Database.Redis.ManualCommands

Show Aggregate Source # 
Instance details

Defined in Database.Redis.ManualCommands

data SortOrder Source #

Constructors

Asc 
Desc 

Instances

Instances details
Eq SortOrder Source # 
Instance details

Defined in Database.Redis.ManualCommands

Show SortOrder Source # 
Instance details

Defined in Database.Redis.ManualCommands

data SortOpts Source #

Options for the sort command.

Instances

Instances details
Eq SortOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

Show SortOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

data Slowlog Source #

A single entry from the slowlog.

Constructors

Slowlog 

Fields

Instances

Instances details
Eq Slowlog Source # 
Instance details

Defined in Database.Redis.ManualCommands

Methods

(==) :: Slowlog -> Slowlog -> Bool #

(/=) :: Slowlog -> Slowlog -> Bool #

Show Slowlog Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult Slowlog Source # 
Instance details

Defined in Database.Redis.ManualCommands

objectRefcount Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

objectIdletime Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

objectEncoding Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f ByteString) 

linsertBefore Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

pivot

-> ByteString

value

-> m (f Integer) 

linsertAfter Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

pivot

-> ByteString

value

-> m (f Integer) 

getType Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f RedisType) 

slowlogGet Source #

Arguments

:: RedisCtx m f 
=> Integer

cnt

-> m (f [Slowlog]) 

zrange Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

start

-> Integer

stop

-> m (f [ByteString]) 

zrangeWithscores Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

start

-> Integer

stop

-> m (f [(ByteString, Double)]) 

zrevrange Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

start

-> Integer

stop

-> m (f [ByteString]) 

zrevrangeWithscores Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

start

-> Integer

stop

-> m (f [(ByteString, Double)]) 

zrangebyscore Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

min

-> Double

max

-> m (f [ByteString]) 

zrangebyscoreWithscores Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

min

-> Double

max

-> m (f [(ByteString, Double)]) 

zrangebyscoreLimit Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

min

-> Double

max

-> Integer

offset

-> Integer

count

-> m (f [ByteString]) 

zrangebyscoreWithscoresLimit Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

min

-> Double

max

-> Integer

offset

-> Integer

count

-> m (f [(ByteString, Double)]) 

zrevrangebyscore Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

max

-> Double

min

-> m (f [ByteString]) 

zrevrangebyscoreWithscores Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

max

-> Double

min

-> m (f [(ByteString, Double)]) 

zrevrangebyscoreLimit Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

max

-> Double

min

-> Integer

offset

-> Integer

count

-> m (f [ByteString]) 

zrevrangebyscoreWithscoresLimit Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

max

-> Double

min

-> Integer

offset

-> Integer

count

-> m (f [(ByteString, Double)]) 

defaultSortOpts :: SortOpts Source #

Redis default SortOpts. Equivalent to omitting all optional parameters.

SortOpts
    { sortBy    = Nothing -- omit the BY option
    , sortLimit = (0,-1)  -- return entire collection
    , sortGet   = []      -- omit the GET option
    , sortOrder = Asc     -- sort in ascending order
    , sortAlpha = False   -- sort numerically, not lexicographically
    }

sortStore Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

destination

-> SortOpts 
-> m (f Integer) 

sort Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> SortOpts 
-> m (f [ByteString]) 

zunionstore Source #

Arguments

:: RedisCtx m f 
=> ByteString

destination

-> [ByteString]

keys

-> Aggregate 
-> m (f Integer) 

zunionstoreWeights Source #

Arguments

:: RedisCtx m f 
=> ByteString

destination

-> [(ByteString, Double)]

weighted keys

-> Aggregate 
-> m (f Integer) 

zinterstore Source #

Arguments

:: RedisCtx m f 
=> ByteString

destination

-> [ByteString]

keys

-> Aggregate 
-> m (f Integer) 

zinterstoreWeights Source #

Arguments

:: RedisCtx m f 
=> ByteString

destination

-> [(ByteString, Double)]

weighted keys

-> Aggregate 
-> m (f Integer) 

eval Source #

Arguments

:: (RedisCtx m f, RedisResult a) 
=> ByteString

script

-> [ByteString]

keys

-> [ByteString]

args

-> m (f a) 

evalsha Source #

Arguments

:: (RedisCtx m f, RedisResult a) 
=> ByteString

base16-encoded sha1 hash of the script

-> [ByteString]

keys

-> [ByteString]

args

-> m (f a) 

Works like eval, but sends the SHA1 hash of the script instead of the script itself. Fails if the server does not recognise the hash, in which case, eval should be used instead.

bitcount Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

bitcountRange Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

start

-> Integer

end

-> m (f Integer) 

bitopAnd Source #

Arguments

:: RedisCtx m f 
=> ByteString

destkey

-> [ByteString]

srckeys

-> m (f Integer) 

bitopOr Source #

Arguments

:: RedisCtx m f 
=> ByteString

destkey

-> [ByteString]

srckeys

-> m (f Integer) 

bitopXor Source #

Arguments

:: RedisCtx m f 
=> ByteString

destkey

-> [ByteString]

srckeys

-> m (f Integer) 

bitopNot Source #

Arguments

:: RedisCtx m f 
=> ByteString

destkey

-> ByteString

srckey

-> m (f Integer) 

migrate Source #

Arguments

:: RedisCtx m f 
=> ByteString

host

-> ByteString

port

-> ByteString

key

-> Integer

destinationDb

-> Integer

timeout

-> m (f Status) 

defaultMigrateOpts :: MigrateOpts Source #

Redis default MigrateOpts. Equivalent to omitting all optional parameters.

MigrateOpts
    { migrateCopy    = False -- remove the key from the local instance
    , migrateReplace = False -- don't replace existing key on the remote instance
    }

migrateMultiple Source #

Arguments

:: RedisCtx m f 
=> ByteString

host

-> ByteString

port

-> Integer

destinationDb

-> Integer

timeout

-> MigrateOpts 
-> [ByteString]

keys

-> m (f Status) 

restore Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

timeToLive

-> ByteString

serializedValue

-> m (f Status) 

restoreReplace Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

timeToLive

-> ByteString

serializedValue

-> m (f Status) 

set Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

value

-> m (f Status) 

setOpts Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

value

-> SetOpts 
-> m (f Status) 

zadd Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [(Double, ByteString)]

scoreMember

-> m (f Integer) 

defaultZaddOpts :: ZaddOpts Source #

Redis default ZaddOpts. Equivalent to omitting all optional parameters.

ZaddOpts
    { zaddCondition = Nothing -- omit NX and XX options
    , zaddChange    = False   -- don't modify the return value from the number of new elements added, to the total number of elements changed
    , zaddIncrement = False   -- don't add like ZINCRBY
    }

zaddOpts Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [(Double, ByteString)]

scoreMember

-> ZaddOpts

options

-> m (f Integer) 

srandmember Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f (Maybe ByteString)) 

srandmemberN Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

count

-> m (f [ByteString]) 

spop Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f (Maybe ByteString)) 

spopN Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

count

-> m (f [ByteString]) 

info :: RedisCtx m f => m (f ByteString) Source #

infoSection Source #

Arguments

:: RedisCtx m f 
=> ByteString

section

-> m (f ByteString) 

exists Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Bool) 

scan Source #

Arguments

:: RedisCtx m f 
=> Cursor 
-> m (f (Cursor, [ByteString]))

next cursor and values

defaultScanOpts :: ScanOpts Source #

Redis default ScanOpts. Equivalent to omitting all optional parameters.

ScanOpts
    { scanMatch = Nothing -- don't match any pattern
    , scanCount = Nothing -- don't set any requirements on number elements returned (works like value COUNT 10)
    }

scanOpts Source #

Arguments

:: RedisCtx m f 
=> Cursor 
-> ScanOpts 
-> m (f (Cursor, [ByteString]))

next cursor and values

sscan Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Cursor 
-> m (f (Cursor, [ByteString]))

next cursor and values

sscanOpts Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Cursor 
-> ScanOpts 
-> m (f (Cursor, [ByteString]))

next cursor and values

hscan Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Cursor 
-> m (f (Cursor, [(ByteString, ByteString)]))

next cursor and values

hscanOpts Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Cursor 
-> ScanOpts 
-> m (f (Cursor, [(ByteString, ByteString)]))

next cursor and values

zscan Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Cursor 
-> m (f (Cursor, [(ByteString, Double)]))

next cursor and values

zscanOpts Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Cursor 
-> ScanOpts 
-> m (f (Cursor, [(ByteString, Double)]))

next cursor and values

zrangebylexLimit Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> RangeLex ByteString

min

-> RangeLex ByteString

max

-> Integer

offset

-> Integer

count

-> m (f [ByteString]) 

xaddOpts Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

id

-> [(ByteString, ByteString)]

(field, value)

-> TrimOpts 
-> m (f ByteString) 

xadd Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

id

-> [(ByteString, ByteString)]

(field, value)

-> m (f ByteString) 

defaultXreadOpts :: XReadOpts Source #

Redis default XReadOpts. Equivalent to omitting all optional parameters.

XReadOpts
    { block = Nothing -- Don't block waiting for more records
    , recordCount    = Nothing   -- no record count
    }

xreadOpts Source #

Arguments

:: RedisCtx m f 
=> [(ByteString, ByteString)]

(stream, id) pairs

-> XReadOpts

Options

-> m (f (Maybe [XReadResponse])) 

xread Source #

Arguments

:: RedisCtx m f 
=> [(ByteString, ByteString)]

(stream, id) pairs

-> m (f (Maybe [XReadResponse])) 

xreadGroupOpts Source #

Arguments

:: RedisCtx m f 
=> ByteString

group name

-> ByteString

consumer name

-> [(ByteString, ByteString)]

(stream, id) pairs

-> XReadOpts

Options

-> m (f (Maybe [XReadResponse])) 

xreadGroup Source #

Arguments

:: RedisCtx m f 
=> ByteString

group name

-> ByteString

consumer name

-> [(ByteString, ByteString)]

(stream, id) pairs

-> m (f (Maybe [XReadResponse])) 

xgroupCreate Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

group name

-> ByteString

start ID

-> m (f Status) 

xgroupSetId Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

group

-> ByteString

id

-> m (f Status) 

xgroupDelConsumer Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

group

-> ByteString

consumer

-> m (f Integer) 

xgroupDestroy Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

group

-> m (f Bool) 

xack Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

group name

-> [ByteString]

message IDs

-> m (f Integer) 

xrange Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

start

-> ByteString

end

-> Maybe Integer

COUNT

-> m (f [StreamsRecord]) 

xrevRange Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

end

-> ByteString

start

-> Maybe Integer

COUNT

-> m (f [StreamsRecord]) 

xlen Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> m (f Integer) 

xpendingSummary Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

group

-> Maybe ByteString

consumer

-> m (f XPendingSummaryResponse) 

xpendingDetail Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

group

-> ByteString

startId

-> ByteString

endId

-> Integer

count

-> Maybe ByteString

consumer

-> m (f [XPendingDetailRecord]) 

xclaim Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

group

-> ByteString

consumer

-> Integer

min idle time

-> XClaimOpts

optional arguments

-> [ByteString]

message IDs

-> m (f [StreamsRecord]) 

xclaimJustIds Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

group

-> ByteString

consumer

-> Integer

min idle time

-> XClaimOpts

optional arguments

-> [ByteString]

message IDs

-> m (f [ByteString]) 

xinfoConsumers Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> ByteString

group

-> m (f [XInfoConsumersResponse]) 

xinfoGroups Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> m (f [XInfoGroupsResponse]) 

xinfoStream Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> m (f XInfoStreamResponse) 

xdel Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> [ByteString]

message IDs

-> m (f Integer) 

xtrim Source #

Arguments

:: RedisCtx m f 
=> ByteString

stream

-> TrimOpts 
-> m (f Integer) 

inf :: RealFloat a => a Source #

auth Source #

Arguments

:: RedisCtx m f 
=> ByteString

password

-> m (f Status) 

select Source #

Arguments

:: RedisCtx m f 
=> Integer

index

-> m (f Status) 

ping :: RedisCtx m f => m (f Status) Source #

command :: RedisCtx m f => m (f [CommandInfo]) Source #

ttl Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

setnx Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

value

-> m (f Bool) 

pttl Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

clientSetname Source #

Arguments

:: RedisCtx m f 
=> ByteString

connectionName

-> m (f ByteString) 

zrank Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

member

-> m (f (Maybe Integer)) 

zremrangebyscore Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

min

-> Double

max

-> m (f Integer) 

hkeys Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f [ByteString]) 

slaveof Source #

Arguments

:: RedisCtx m f 
=> ByteString

host

-> ByteString

port

-> m (f Status) 

rpushx Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

value

-> m (f Integer) 

debugObject Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f ByteString) 

bgsave :: RedisCtx m f => m (f Status) Source #

hlen Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

rpoplpush Source #

Arguments

:: RedisCtx m f 
=> ByteString

source

-> ByteString

destination

-> m (f (Maybe ByteString)) 

brpop Source #

Arguments

:: RedisCtx m f 
=> [ByteString]

key

-> Integer

timeout

-> m (f (Maybe (ByteString, ByteString))) 

zincrby Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

increment

-> ByteString

member

-> m (f Double) 

hgetall Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f [(ByteString, ByteString)]) 

hmset Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [(ByteString, ByteString)]

fieldValue

-> m (f Status) 

sinter Source #

Arguments

:: RedisCtx m f 
=> [ByteString]

key

-> m (f [ByteString]) 

pfadd Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [ByteString]

value

-> m (f Integer) 

zremrangebyrank Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

start

-> Integer

stop

-> m (f Integer) 

flushdb :: RedisCtx m f => m (f Status) Source #

sadd Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [ByteString]

member

-> m (f Integer) 

lindex Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

index

-> m (f (Maybe ByteString)) 

lpush Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [ByteString]

value

-> m (f Integer) 

hstrlen Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

field

-> m (f Integer) 

smove Source #

Arguments

:: RedisCtx m f 
=> ByteString

source

-> ByteString

destination

-> ByteString

member

-> m (f Bool) 

zscore Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

member

-> m (f (Maybe Double)) 

pfcount Source #

Arguments

:: RedisCtx m f 
=> [ByteString]

key

-> m (f Integer) 

hdel Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [ByteString]

field

-> m (f Integer) 

incrbyfloat Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

increment

-> m (f Double) 

setbit Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

offset

-> ByteString

value

-> m (f Integer) 

flushall :: RedisCtx m f => m (f Status) Source #

incrby Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

increment

-> m (f Integer) 

time :: RedisCtx m f => m (f (Integer, Integer)) Source #

smembers Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f [ByteString]) 

zlexcount Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

min

-> ByteString

max

-> m (f Integer) 

sunion Source #

Arguments

:: RedisCtx m f 
=> [ByteString]

key

-> m (f [ByteString]) 

sinterstore Source #

Arguments

:: RedisCtx m f 
=> ByteString

destination

-> [ByteString]

key

-> m (f Integer) 

hvals Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f [ByteString]) 

configSet Source #

Arguments

:: RedisCtx m f 
=> ByteString

parameter

-> ByteString

value

-> m (f Status) 

dbsize :: RedisCtx m f => m (f Integer) Source #

wait Source #

Arguments

:: RedisCtx m f 
=> Integer

numslaves

-> Integer

timeout

-> m (f Integer) 

lpop Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f (Maybe ByteString)) 

clientPause Source #

Arguments

:: RedisCtx m f 
=> Integer

timeout

-> m (f Status) 

expire Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

seconds

-> m (f Bool) 

mget Source #

Arguments

:: RedisCtx m f 
=> [ByteString]

key

-> m (f [Maybe ByteString]) 

bitpos Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

bit

-> Integer

start

-> Integer

end

-> m (f Integer) 

lastsave :: RedisCtx m f => m (f Integer) Source #

pexpire Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

milliseconds

-> m (f Bool) 

renamenx Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

newkey

-> m (f Bool) 

pfmerge Source #

Arguments

:: RedisCtx m f 
=> ByteString

destkey

-> [ByteString]

sourcekey

-> m (f ByteString) 

lrem Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

count

-> ByteString

value

-> m (f Integer) 

sdiff Source #

Arguments

:: RedisCtx m f 
=> [ByteString]

key

-> m (f [ByteString]) 

get Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f (Maybe ByteString)) 

getrange Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

start

-> Integer

end

-> m (f ByteString) 

sdiffstore Source #

Arguments

:: RedisCtx m f 
=> ByteString

destination

-> [ByteString]

key

-> m (f Integer) 

zcount Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Double

min

-> Double

max

-> m (f Integer) 

scriptLoad Source #

Arguments

:: RedisCtx m f 
=> ByteString

script

-> m (f ByteString) 

getset Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

value

-> m (f (Maybe ByteString)) 

dump Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f ByteString) 

keys Source #

Arguments

:: RedisCtx m f 
=> ByteString

pattern

-> m (f [ByteString]) 

configGet Source #

Arguments

:: RedisCtx m f 
=> ByteString

parameter

-> m (f [(ByteString, ByteString)]) 

rpush Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [ByteString]

value

-> m (f Integer) 

hsetnx Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

field

-> ByteString

value

-> m (f Bool) 

mset Source #

Arguments

:: RedisCtx m f 
=> [(ByteString, ByteString)]

keyValue

-> m (f Status) 

setex Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

seconds

-> ByteString

value

-> m (f Status) 

psetex Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

milliseconds

-> ByteString

value

-> m (f Status) 

scard Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

scriptExists Source #

Arguments

:: RedisCtx m f 
=> [ByteString]

script

-> m (f [Bool]) 

sunionstore Source #

Arguments

:: RedisCtx m f 
=> ByteString

destination

-> [ByteString]

key

-> m (f Integer) 

persist Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Bool) 

strlen Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

lpushx Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

value

-> m (f Integer) 

hset Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

field

-> ByteString

value

-> m (f Integer) 

brpoplpush Source #

Arguments

:: RedisCtx m f 
=> ByteString

source

-> ByteString

destination

-> Integer

timeout

-> m (f (Maybe ByteString)) 

zrevrank Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

member

-> m (f (Maybe Integer)) 

setrange Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

offset

-> ByteString

value

-> m (f Integer) 

del Source #

Arguments

:: RedisCtx m f 
=> [ByteString]

key

-> m (f Integer) 

hincrbyfloat Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

field

-> Double

increment

-> m (f Double) 

hincrby Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

field

-> Integer

increment

-> m (f Integer) 

zremrangebylex Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

min

-> ByteString

max

-> m (f Integer) 

rpop Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f (Maybe ByteString)) 

rename Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

newkey

-> m (f Status) 

zrem Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [ByteString]

member

-> m (f Integer) 

hexists Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

field

-> m (f Bool) 

decr Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

hmget Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [ByteString]

field

-> m (f [Maybe ByteString]) 

lrange Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

start

-> Integer

stop

-> m (f [ByteString]) 

decrby Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

decrement

-> m (f Integer) 

llen Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

append Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

value

-> m (f Integer) 

incr Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

hget Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

field

-> m (f (Maybe ByteString)) 

pexpireat Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

millisecondsTimestamp

-> m (f Bool) 

ltrim Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

start

-> Integer

stop

-> m (f Status) 

zcard Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> m (f Integer) 

lset Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

index

-> ByteString

value

-> m (f Status) 

expireat Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

timestamp

-> m (f Bool) 

save :: RedisCtx m f => m (f Status) Source #

move Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

db

-> m (f Bool) 

getbit Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> Integer

offset

-> m (f Integer) 

msetnx Source #

Arguments

:: RedisCtx m f 
=> [(ByteString, ByteString)]

keyValue

-> m (f Bool) 

commandInfo Source #

Arguments

:: RedisCtx m f 
=> [ByteString]

commandName

-> m (f [ByteString]) 

quit :: RedisCtx m f => m (f Status) Source #

blpop Source #

Arguments

:: RedisCtx m f 
=> [ByteString]

key

-> Integer

timeout

-> m (f (Maybe (ByteString, ByteString))) 

srem Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> [ByteString]

member

-> m (f Integer) 

echo Source #

Arguments

:: RedisCtx m f 
=> ByteString

message

-> m (f ByteString) 

sismember Source #

Arguments

:: RedisCtx m f 
=> ByteString

key

-> ByteString

member

-> m (f Bool) 

data ConnectInfo Source #

Information for connnecting to a Redis server.

It is recommended to not use the ConnInfo data constructor directly. Instead use defaultConnectInfo and update it with record syntax. For example to connect to a password protected Redis server running on localhost and listening to the default port:

myConnectInfo :: ConnectInfo
myConnectInfo = defaultConnectInfo {connectAuth = Just "secret"}

Constructors

ConnInfo 

Fields

Instances

Instances details
Show ConnectInfo Source # 
Instance details

Defined in Database.Redis.Connection

defaultConnectInfo :: ConnectInfo Source #

Default information for connecting:

 connectHost           = "localhost"
 connectPort           = PortNumber 6379 -- Redis default port
 connectAuth           = Nothing         -- No password
 connectDatabase       = 0               -- SELECT database 0
 connectMaxConnections = 50              -- Up to 50 connections
 connectMaxIdleTime    = 30              -- Keep open for 30 seconds
 connectTimeout        = Nothing         -- Don't add timeout logic
 connectTLSParams      = Nothing         -- Do not use TLS

checkedConnect :: ConnectInfo -> IO Connection Source #

Constructs a Connection pool to a Redis server designated by the given ConnectInfo, then tests if the server is actually there. Throws an exception if the connection to the Redis server can't be established.

disconnect :: Connection -> IO () Source #

Destroy all idle resources in the pool.

withConnect :: (MonadMask m, MonadIO m) => ConnectInfo -> (Connection -> m c) -> m c Source #

Memory bracket around connect and disconnect.

withCheckedConnect :: ConnectInfo -> (Connection -> IO c) -> IO c Source #

Memory bracket around checkedConnect and disconnect

connectCluster :: ConnectInfo -> IO Connection Source #

Constructs a ShardMap of connections to clustered nodes. The argument is a ConnectInfo for any node in the cluster

Some Redis commands are currently not supported in cluster mode - CONFIG, AUTH - SCAN - MOVE, SELECT - PUBLISH, SUBSCRIBE, PSUBSCRIBE, UNSUBSCRIBE, PUNSUBSCRIBE, RESET

data PubSubController Source #

A controller that stores a set of channels, pattern channels, and callbacks. It allows you to manage Pub/Sub subscriptions and pattern subscriptions and alter them at any time throughout the life of your program. You should typically create the controller at the start of your program and then store it through the life of your program, using addChannels and removeChannels to update the current subscriptions.

type UnregisterCallbacksAction = IO () Source #

An action that when executed will unregister the callbacks. It is returned from addChannels or addChannelsAndWait and typically you would use it in bracket to guarantee that you unsubscribe from channels. For example, if you are using websockets to distribute messages to clients, you could use something such as:

websocketConn <- Network.WebSockets.acceptRequest pending
let mycallback msg = Network.WebSockets.sendTextData websocketConn msg
bracket (addChannelsAndWait ctrl [("hello", mycallback)] []) id $ const $ do
  {- loop here calling Network.WebSockets.receiveData -}

type PMessageCallback = RedisChannel -> ByteString -> IO () Source #

A handler for a message from a psubscribed channel. The callback is passed the channel the message was sent on plus the message content.

Similar to MessageCallback, callbacks are executed synchronously and any exceptions are rethrown from pubSubForever.

type MessageCallback = ByteString -> IO () Source #

A handler for a message from a subscribed channel. The callback is passed the message content.

Messages are processed synchronously in the receiving thread, so if the callback takes a long time it will block other callbacks and other messages from being received. If you need to move long-running work to a different thread, we suggest you use TBQueue with a reasonable bound, so that if messages are arriving faster than you can process them, you do eventually block.

If the callback throws an exception, the exception will be thrown from pubSubForever which will cause the entire Redis connection for all subscriptions to be closed. As long as you call pubSubForever in a loop you will reconnect to your subscribed channels, but you should probably add an exception handler to each callback to prevent this.

type RedisPChannel = ByteString Source #

A Redis pattern channel name

type RedisChannel = ByteString Source #

A Redis channel name

data Message Source #

Instances

Instances details
Show Message Source # 
Instance details

Defined in Database.Redis.PubSub

data PubSub Source #

Encapsulates subscription changes. Use subscribe, unsubscribe, psubscribe, punsubscribe or mempty to construct a value. Combine values by using the Monoid interface, i.e. mappend and mconcat.

Instances

Instances details
Eq PubSub Source # 
Instance details

Defined in Database.Redis.PubSub

Methods

(==) :: PubSub -> PubSub -> Bool #

(/=) :: PubSub -> PubSub -> Bool #

Semigroup PubSub Source # 
Instance details

Defined in Database.Redis.PubSub

Monoid PubSub Source # 
Instance details

Defined in Database.Redis.PubSub

publish Source #

Arguments

:: RedisCtx m f 
=> ByteString

channel

-> ByteString

message

-> m (f Integer) 

Post a message to a channel (http://redis.io/commands/publish).

subscribe Source #

Arguments

:: [ByteString]

channel

-> PubSub 

Listen for messages published to the given channels (http://redis.io/commands/subscribe).

unsubscribe Source #

Arguments

:: [ByteString]

channel

-> PubSub 

Stop listening for messages posted to the given channels (http://redis.io/commands/unsubscribe).

psubscribe Source #

Arguments

:: [ByteString]

pattern

-> PubSub 

Listen for messages published to channels matching the given patterns (http://redis.io/commands/psubscribe).

punsubscribe Source #

Arguments

:: [ByteString]

pattern

-> PubSub 

Stop listening for messages posted to channels matching the given patterns (http://redis.io/commands/punsubscribe).

pubSub Source #

Arguments

:: PubSub

Initial subscriptions.

-> (Message -> IO PubSub)

Callback function.

-> Redis () 

Listens to published messages on subscribed channels and channels matching the subscribed patterns. For documentation on the semantics of Redis Pub/Sub see http://redis.io/topics/pubsub.

The given callback function is called for each received message. Subscription changes are triggered by the returned PubSub. To keep subscriptions unchanged, the callback can return mempty.

Example: Subscribe to the "news" channel indefinitely.

 pubSub (subscribe ["news"]) $ \msg -> do
     putStrLn $ "Message from " ++ show (msgChannel msg)
     return mempty
 

Example: Receive a single message from the "chat" channel.

 pubSub (subscribe ["chat"]) $ \msg -> do
     putStrLn $ "Message from " ++ show (msgChannel msg)
     return $ unsubscribe ["chat"]
 

It should be noted that Redis Pub/Sub by its nature is asynchronous so returning unsubscribe does not mean that callback won't be able to receive any further messages. And to guarantee that you won't won't process messages after unsubscription and won't unsubscribe from the same channel more than once you need to use IORef or something similar

newPubSubController Source #

Arguments

:: MonadIO m 
=> [(RedisChannel, MessageCallback)]

the initial subscriptions

-> [(RedisPChannel, PMessageCallback)]

the initial pattern subscriptions

-> m PubSubController 

Create a new PubSubController. Note that this does not subscribe to any channels, it just creates the controller. The subscriptions will happen once pubSubForever is called.

currentChannels :: MonadIO m => PubSubController -> m [RedisChannel] Source #

Get the list of current channels in the PubSubController. WARNING! This might not exactly reflect the subscribed channels in the Redis server, because there is a delay between adding or removing a channel in the PubSubController and when Redis receives and processes the subscription change request.

currentPChannels :: MonadIO m => PubSubController -> m [RedisPChannel] Source #

Get the list of current pattern channels in the PubSubController. WARNING! This might not exactly reflect the subscribed channels in the Redis server, because there is a delay between adding or removing a channel in the PubSubController and when Redis receives and processes the subscription change request.

addChannels Source #

Arguments

:: MonadIO m 
=> PubSubController 
-> [(RedisChannel, MessageCallback)]

the channels to subscribe to

-> [(RedisPChannel, PMessageCallback)]

the channels to pattern subscribe to

-> m UnregisterCallbacksAction 

Add channels into the PubSubController, and if there is an active pubSubForever, send the subscribe and psubscribe commands to Redis. The addChannels function is thread-safe. This function does not wait for Redis to acknowledge that the channels have actually been subscribed; use addChannelsAndWait for that.

You can subscribe to the same channel or pattern channel multiple times; the PubSubController keeps a list of callbacks and executes each callback in response to a message.

The return value is an action UnregisterCallbacksAction which will unregister the callbacks, which should typically used with bracket.

addChannelsAndWait Source #

Arguments

:: MonadIO m 
=> PubSubController 
-> [(RedisChannel, MessageCallback)]

the channels to subscribe to

-> [(RedisPChannel, PMessageCallback)]

the channels to psubscribe to

-> m UnregisterCallbacksAction 

Call addChannels and then wait for Redis to acknowledge that the channels are actually subscribed.

Note that this function waits for all pending subscription change requests, so if you for example call addChannelsAndWait from multiple threads simultaneously, they all will wait for all pending subscription changes to be acknowledged by Redis (this is due to the fact that we just track the total number of pending change requests sent to Redis and just wait until that count reaches zero).

This also correctly waits if the network connection dies during the subscription change. Say that the network connection dies right after we send a subscription change to Redis. pubSubForever will throw ConnectionLost and addChannelsAndWait will continue to wait. Once you recall pubSubForever with the same PubSubController, pubSubForever will open a new connection, send subscription commands for all channels in the PubSubController (which include the ones we are waiting for), and wait for the responses from Redis. Only once we receive the response from Redis that it has subscribed to all channels in PubSubController will addChannelsAndWait unblock and return.

removeChannels :: MonadIO m => PubSubController -> [RedisChannel] -> [RedisPChannel] -> m () Source #

Remove channels from the PubSubController, and if there is an active pubSubForever, send the unsubscribe commands to Redis. Note that as soon as this function returns, no more callbacks will be executed even if more messages arrive during the period when we request to unsubscribe from the channel and Redis actually processes the unsubscribe request. This function is thread-safe.

If you remove all channels, the connection in pubSubForever to redis will stay open and waiting for any new channels from a call to addChannels. If you really want to close the connection, use killThread or cancel to kill the thread running pubSubForever.

removeChannelsAndWait :: MonadIO m => PubSubController -> [RedisChannel] -> [RedisPChannel] -> m () Source #

Call removeChannels and then wait for all pending subscription change requests to be acknowledged by Redis. This uses the same waiting logic as addChannelsAndWait. Since removeChannels immediately notifies the PubSubController to start discarding messages, you likely don't need this function and can just use removeChannels.

pubSubForever Source #

Arguments

:: Connection

The connection pool

-> PubSubController

The controller which keeps track of all subscriptions and handlers

-> IO ()

This action is executed once Redis acknowledges that all the subscriptions in the controller are now subscribed. You can use this after an exception (such as ConnectionLost) to signal that all subscriptions are now reactivated.

-> IO () 

Open a connection to the Redis server, register to all channels in the PubSubController, and process messages and subscription change requests forever. The only way this will ever exit is if there is an exception from the network code or an unhandled exception in a MessageCallback or PMessageCallback. For example, if the network connection to Redis dies, pubSubForever will throw a ConnectionLost. When such an exception is thrown, you can recall pubSubForever with the same PubSubController which will open a new connection and resubscribe to all the channels which are tracked in the PubSubController.

The general pattern is therefore during program startup create a PubSubController and fork a thread which calls pubSubForever in a loop (using an exponential backoff algorithm such as the retry package to not hammer the Redis server if it does die). For example,

myhandler :: ByteString -> IO ()
myhandler msg = putStrLn $ unpack $ decodeUtf8 msg

onInitialComplete :: IO ()
onInitialComplete = putStrLn "Redis acknowledged that mychannel is now subscribed"

main :: IO ()
main = do
  conn <- connect defaultConnectInfo
  pubSubCtrl <- newPubSubController [("mychannel", myhandler)] []
  concurrently ( forever $
      pubSubForever conn pubSubCtrl onInitialComplete
        `catch` (\(e :: SomeException) -> do
          putStrLn $ "Got error: " ++ show e
          threadDelay $ 50*1000) -- TODO: use exponential backoff
       ) $ restOfYourProgram


  {- elsewhere in your program, use pubSubCtrl to change subscriptions -}

At most one active pubSubForever can be running against a single PubSubController at any time. If two active calls to pubSubForever share a single PubSubController there will be deadlocks. If you do want to process messages using multiple connections to Redis, you can create more than one PubSubController. For example, create one PubSubController for each getNumCapabilities and then create a Haskell thread bound to each capability each calling pubSubForever in a loop. This will create one network connection per controller/capability and allow you to register separate channels and callbacks for each controller, spreading the load across the capabilities.

parseConnectInfo :: String -> Either String ConnectInfo Source #

Parse a ConnectInfo from a URL

Username is ignored, path is used to specify the database:

>>> parseConnectInfo "redis://username:password@host:42/2"
Right (ConnInfo {connectHost = "host", connectPort = PortNumber 42, connectAuth = Just "password", connectDatabase = 2, connectMaxConnections = 50, connectMaxIdleTime = 30s, connectTimeout = Nothing, connectTLSParams = Nothing})
>>> parseConnectInfo "redis://username:password@host:42/db"
Left "Invalid port: db"

The scheme is validated, to prevent mixing up configurations:

>>> parseConnectInfo "postgres://"
Left "Wrong scheme"

Beyond that, all values are optional. Omitted values are taken from defaultConnectInfo:

>>> parseConnectInfo "redis://"
Right (ConnInfo {connectHost = "localhost", connectPort = PortNumber 6379, connectAuth = Nothing, connectDatabase = 0, connectMaxConnections = 50, connectMaxIdleTime = 30s, connectTimeout = Nothing, connectTLSParams = Nothing})