| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Database.Redis
Synopsis
- data Connection
- data ConnectInfo = ConnInfo {
- connectAddr :: !ConnectAddr
- connectAuth :: !(Maybe ByteString)
- connectUsername :: !(Maybe ByteString)
- connectDatabase :: !Integer
- connectMaxConnections :: !Int
- connectNumStripes :: !(Maybe Int)
- connectMaxIdleTime :: !NominalDiffTime
- connectTimeout :: !(Maybe NominalDiffTime)
- connectTLSParams :: !(Maybe ClientParams)
- connectHooks :: !Hooks
- connectPoolLabel :: !Text
- data ConnectAddr
- defaultConnectInfo :: ConnectInfo
- parseConnectInfo :: String -> Either String ConnectInfo
- disconnect :: Connection -> IO ()
- connect :: ConnectInfo -> IO Connection
- checkedConnect :: ConnectInfo -> IO Connection
- withConnect :: (MonadMask m, MonadIO m) => ConnectInfo -> (Connection -> m c) -> m c
- withCheckedConnect :: ConnectInfo -> (Connection -> IO c) -> IO c
- data ConnectError
- connectCluster :: ConnectInfo -> IO Connection
- checkedConnectCluster :: ConnectInfo -> IO Connection
- newtype ClusterConnectError = ClusterConnectError Reply
- module Database.Redis.Commands
- module Database.Redis.Transactions
- module Database.Redis.PubSub
- data Redis a
- runRedis :: Connection -> Redis a -> IO a
- runRedisNonBlocking :: Connection -> Redis a -> IO (Maybe a)
- unRedis :: Redis a -> ReaderT RedisEnv IO a
- reRedis :: ReaderT RedisEnv IO a -> Redis a
- class MonadRedis m => RedisCtx (m :: Type -> Type) (f :: Type -> Type) | m -> f where
- returnDecode :: RedisResult a => Reply -> m (f a)
- class Monad m => MonadRedis (m :: Type -> Type) where
- data Hooks = Hooks {}
- type SendRequestHook = ([ByteString] -> IO Reply) -> [ByteString] -> IO Reply
- type SendPubSubHook = ([ByteString] -> IO ()) -> [ByteString] -> IO ()
- type CallbackHook = (Message -> IO PubSub) -> Message -> IO PubSub
- type SendHook = (ByteString -> IO ()) -> ByteString -> IO ()
- type ReceiveHook = IO Reply -> IO Reply
- defaultHooks :: Hooks
- sendRequest :: (RedisCtx m f, RedisResult a) => [ByteString] -> m (f a)
- data Reply
- = SingleLine ByteString
- | Error ByteString
- | Integer Integer
- | Bulk (Maybe ByteString)
- | MultiBulk (Maybe [Reply])
- data Status
- = Ok
- | Pong
- | Status ByteString
- class RedisArg a where
- encode :: a -> ByteString
- class RedisResult a where
- data ConnectionLostException = ConnectionLost
- newtype ConnectTimeout = ConnectTimeout ConnectPhase
- data HashSlot
- keyToSlot :: ByteString -> HashSlot
How To Use This Package
Simplest usage of this package is to connect to a Redis server and run commands against it and close connection when done:
Connect to a Redis server:
let Right ci =parseConnectInfo"redis://localhost:6379" conn <-checkedConnectci
connect or checkedConnect creates a connection pool under the hood. This poll manages reuse of the connections connection livetimes,
and connection restore in the case of the connection loss.
Send commands to the server:
{-# LANGUAGE OverloadedStrings #-}
...
runRedis conn $ do
set "hello" "hello"
set "world" "world"
hello <- get "hello"
world <- get "world"
liftIO $ print (hello,world)
disconnect all idle resources in the connection pool, and destroy the pool:
disconnectconn
Managing connections
Redis connections are managed by a connection pool enclosed in the Connection type, that keeps all required state.
data Connection Source #
A threadsafe pool of network connections to a Redis server. Use the
connect function to create one.
To create a connection one need to contruct a ConnectInfo record.
The easiest way to do this is to use the parseConnectInfo function, which takes a URL and returns a ConnectInfo record.
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"}
Or better yet, use parseConnectInfo to parse a URL.
Constructors
| ConnInfo | |
Fields
| |
Instances
| Show ConnectInfo Source # | |
Defined in Database.Redis.Connection Methods showsPrec :: Int -> ConnectInfo -> ShowS # show :: ConnectInfo -> String # showList :: [ConnectInfo] -> ShowS # | |
data ConnectAddr Source #
Constructors
| ConnectAddrHostPort HostName PortNumber | |
| ConnectAddrUnixSocket String |
Instances
| Show ConnectAddr Source # | |
Defined in Database.Redis.ConnectionContext Methods showsPrec :: Int -> ConnectAddr -> ShowS # show :: ConnectAddr -> String # showList :: [ConnectAddr] -> ShowS # | |
| Eq ConnectAddr Source # | |
Defined in Database.Redis.ConnectionContext | |
defaultConnectInfo :: ConnectInfo Source #
Default information for connecting:
connectAddr = ConnectAddrHostPort "localhost" 6379 -- Redis default port connectAuth = Nothing -- No password connectUsername = Nothing -- No user connectDatabase = 0 -- SELECT database 0 connectMaxConnections = 50 -- Up to 50 connections connectNumStripes = Just 1 -- A single stripe connectMaxIdleTime = 30 -- Keep open for 30 seconds connectTimeout = Nothing -- Don't add timeout logic connectTLSParams = Nothing -- Do not use TLS connectHooks = defaultHooks -- Do nothing connectPoolLabel = "" -- no label
parseConnectInfo :: String -> Either String ConnectInfo Source #
Parse a from a URL according to the Rules in Redis clientConnectInfo
Standalone Redis:
redis :// [[username :] password@] host [:port][/database]
>>>parseConnectInfo "redis://username:password@host:42/2"Right (ConnInfo {connectAddr = ConnectAddrHostPort "host" 42, connectAuth = Just "password", connectUsername = Just "username", connectDatabase = 2, connectMaxConnections = 50, connectNumStripes = Just 1, connectMaxIdleTime = 30s, connectTimeout = Nothing, connectTLSParams = Nothing, connectHooks = Hooks {...}, connectPoolLabel = ""})
>>>parseConnectInfo "redis://password@host:42/2"Right (ConnInfo {connectAddr = ConnectAddrHostPort "host" 42, connectAuth = Just "password", connectUsername = Nothing, connectDatabase = 2, connectMaxConnections = 50, connectNumStripes = Just 1, connectMaxIdleTime = 30s, connectTimeout = Nothing, connectTLSParams = Nothing, connectHooks = Hooks {...}, connectPoolLabel = ""})
TLS-enabled Redis:
rediss :// [[username :] password@] host [: port][/database]
Unix socket Redis:
redis-socket :// [[username :] password@]path [? [&database=database]
>>>parseConnectInfo "redis-socket://password@/tmp/redis.sock?database=2"Right (ConnInfo {connectAddr = ConnectAddrUnixSocket "/tmp/redis.sock", connectAuth = Just "password", connectUsername = Nothing, connectDatabase = 2, connectMaxConnections = 50, connectNumStripes = Just 1, connectMaxIdleTime = 30s, connectTimeout = Nothing, connectTLSParams = Nothing, connectHooks = Hooks {...}, connectPoolLabel = ""})
>>>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 postgres:"
Beyond that, all values are optional. Omitted values are taken from
:defaultConnectInfo
>>>parseConnectInfo "rediss://"Right (ConnInfo {connectAddr = ConnectAddrHostPort "localhost" 6379, connectAuth = Nothing, connectUsername = Nothing, connectDatabase = 0, connectMaxConnections = 50, connectNumStripes = Just 1, connectMaxIdleTime = 30s, connectTimeout = Nothing, connectTLSParams = Just (ClientParams ...), connectHooks = Hooks {...}, connectPoolLabel = ""})
disconnect :: Connection -> IO () Source #
Destroy all idle resources in the pool, works for all types of the connection.
Single node
If you are connecting to a single Redis node, use the connect or checkedConnect functions.
connect :: ConnectInfo -> IO Connection Source #
Constructs a Connection pool to a Redis server designated by the
given ConnectInfo.
The function always succeeds, because the first connection is not actually established until the first call to the server.
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 ConnectError exception if the connection to the Redis server can't be
established.
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
data ConnectError Source #
Constructors
| ConnectAuthError Reply | |
| ConnectSelectError Reply |
Instances
| Exception ConnectError Source # | |
Defined in Database.Redis.Connection Methods toException :: ConnectError -> SomeException # fromException :: SomeException -> Maybe ConnectError # displayException :: ConnectError -> String # backtraceDesired :: ConnectError -> Bool # | |
| Show ConnectError Source # | |
Defined in Database.Redis.Connection Methods showsPrec :: Int -> ConnectError -> ShowS # show :: ConnectError -> String # showList :: [ConnectError] -> ShowS # | |
| Eq ConnectError Source # | |
Defined in Database.Redis.Connection | |
Clustered
If you are connecting to a Redis cluster, use the connectCluster or checkedConnectCluster functions.
At this point, some functions are not supported in the cluster mode:
- CONFIG
- AUTH
- SCAN
- MOVE, SELECT
- RESET
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 - RESET
checkedConnectCluster :: ConnectInfo -> IO Connection Source #
Constructs a Connection pool to a Redis cluster designated by the
given ConnectInfo, then tests if the server is actually there.
Throws an ClusterConnectError exception if the connection to the Redis server can't be
established.
newtype ClusterConnectError Source #
Constructors
| ClusterConnectError Reply |
Instances
| Exception ClusterConnectError Source # | |
Defined in Database.Redis.Connection | |
| Show ClusterConnectError Source # | |
Defined in Database.Redis.Connection Methods showsPrec :: Int -> ClusterConnectError -> ShowS # show :: ClusterConnectError -> String # showList :: [ClusterConnectError] -> ShowS # | |
| Eq ClusterConnectError Source # | |
Defined in Database.Redis.Connection Methods (==) :: ClusterConnectError -> ClusterConnectError -> Bool # (/=) :: ClusterConnectError -> ClusterConnectError -> Bool # | |
Sentinel
If you are connecting to a Redis sentinel, use functions from the Database.Redis.Sentinel module,
such as connect or checkedConnectSentinel.
Those functions live in a separate module to simplify move from the Single-node to Sentinel mode.
Running Commands
Redis commands behave differently when issued in- or outside of a transaction. To make them work in both contexts, most command functions have a type signature similar to the following:
echo:: (RedisCtxm f) => ByteString -> m (f ByteString)
Here is how to interpret this type signature:
- The argument types are independent of the execution context.
echoalways takes aByteStringparameter, whether in- or outside of a transaction. This is true for all command functions. - All Redis commands return their result wrapped in some "container".
The type
fof this container depends on the commands execution contextm. TheByteStringreturn type in the example is specific to theechocommand. For other commands, it will often be another type. - In the "normal" context
Redis, outside of any transactions, results are wrapped in an.EitherReply - Inside a transaction, in the
RedisTxcontext, results are wrapped in aQueued.
In short, you can view any command with a RedisCtx constraint in the
type signature, to "have two types". For example echo "has both
types":
echo :: ByteString -> Redis (Either Reply ByteString) echo :: ByteString -> RedisTx (Queued ByteString)
To see all commands refer to the Database.Redis.Commands module:
module Database.Redis.Commands
It's important to understand several features that the library provides.
Automatic Pipelining
Commands are automatically pipelined as much as possible. For example, in the above "hello world" example, all four commands are pipelined. Automatic pipelining makes use of Haskell's laziness. As long as a previous reply is not evaluated, subsequent commands can be pipelined.
Automatic pipelining is limited to the scope of runRedis call and
it is guaranteed that every reply expected as a part of runRedis
execution gets received after runRedis invocation.
To keep memory usage low, the number of requests "in the pipeline" is limited (per connection) to 1000. After that number, the next command is sent only when at least one reply has been received. That means, command functions may block until there are less than 1000 outstanding replies.
This feature has several implications. Consider the following example:
runRedisconn $ doset"key1" "value1" _ <-get"nonexistingkey"set"key2" "value2"
Even the "nonexistingkey" does not exist and would return a error it does not
prevent commands from execution, so both key1 and key2 will be updated.
To enforce verification of the reply one could wrap commands in ExceptT:
runRedisconn $ runExceptT $ do ExceptT $set"key1" "value1" _ <- ExceptT $get"nonexistingkey" ExceptT $set"key2" "value2"
But this code will break the pipelining and second command will be sent only after first command reply is received.
Error Behavior
- Operations against keys holding the wrong kind of value:
- Outside of a
transaction, if the Redis server returns an
Error, command functions will returnLefttheReply. The library user can inspect the error message to gain information on what kind of error occured. - Connection to the server lost:
- In case of a lost connection, command
functions throw a
ConnectionLostException. It can only be caught outside ofrunRedis. - Trying to connect to an unreachable server:
- When trying to connect to
a server that does not exist or can't be reached, the connection pool
only starts the first connection when actually executing a call to
the server. This can lead to discovering very late that the server is
not available, for example when running a server that logs to Redis.
To prevent this, run a
pingcommand directly after connecting or use thecheckedConnectfunction which encapsulates this behavior. - Exceptions:
- Any exceptions can only be caught outside of
runRedis. This way the connection pool can properly close the connection, making sure it is not left in an unusable state, e.g. closed or inside a transaction.
Transactions
hedis supports Redis transactions. See Database.Redis.Transactions for more information.
module Database.Redis.Transactions
Pub/Sub
hedis supports Redis Pub/Sub. See Database.Redis.PubSub for more information.
module Database.Redis.PubSub
Advanced Usage
The Redis Monad
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
| MonadIO Redis Source # | |
Defined in Database.Redis.Core.Internal | |
| MonadCatch Redis Source # | |
Defined in Database.Redis.Core.Internal | |
| MonadMask Redis Source # | |
Defined in Database.Redis.Core.Internal Methods mask :: HasCallStack => ((forall a. Redis a -> Redis a) -> Redis b) -> Redis b # uninterruptibleMask :: HasCallStack => ((forall a. Redis a -> Redis a) -> Redis b) -> Redis b # generalBracket :: HasCallStack => Redis a -> (a -> ExitCase b -> Redis c) -> (a -> Redis b) -> Redis (b, c) # | |
| MonadThrow Redis Source # | |
Defined in Database.Redis.Core.Internal Methods throwM :: (HasCallStack, Exception e) => e -> Redis a # | |
| Applicative Redis Source # | |
| Functor Redis Source # | |
| Monad Redis Source # | |
| MonadFail Redis Source # | |
Defined in Database.Redis.Core.Internal | |
| MonadRedis Redis Source # | |
| MonadUnliftIO Redis Source # | |
Defined in Database.Redis.Core.Internal | |
| RedisCtx Redis (Either Reply) Source # | |
Defined in Database.Redis.Core Methods returnDecode :: RedisResult a => Reply -> Redis (Either Reply a) Source # | |
runRedis :: Connection -> Redis a -> IO a Source #
Interact with a Redis datastore specified by the given Connection.
Each call of runRedis takes a network connection from the Connection
pool and runs the given Redis action. Calls to runRedis may thus block
while all connections from the pool are in use.
runRedisNonBlocking :: Connection -> Redis a -> IO (Maybe a) Source #
Interact with a Redis datastore specified by the given Connection, but return early
if acquiring from the connection pool would block.
Like runRedis, but if all connections in the Connection pool are used, it
immediately returns Nothing. This can be useful for logging purposes.
class MonadRedis m => RedisCtx (m :: Type -> Type) (f :: Type -> Type) | 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
| RedisCtx RedisTx Queued Source # | |
Defined in Database.Redis.Transactions Methods returnDecode :: RedisResult a => Reply -> RedisTx (Queued a) Source # | |
| RedisCtx Redis (Either Reply) Source # | |
Defined in Database.Redis.Core Methods returnDecode :: RedisResult a => Reply -> Redis (Either Reply a) Source # | |
class Monad m => MonadRedis (m :: Type -> Type) where Source #
Instances
| MonadRedis Redis Source # | |
| MonadRedis RedisTx Source # | |
| (MonadTrans t, MonadRedis m, Monad (t m)) => MonadRedis (t m) Source # | |
Defined in Database.Redis.Core | |
Lua Scripting
Lua values returned from the eval and evalsha functions will be
converted to Haskell values by the decode function from the
RedisResult type class.
Lua Type | Haskell Type | Conversion Example
--------------|--------------------|-----------------------------
Number | Integer | 1.23 => 1
String | ByteString, Double | "1.23" => "1.23" or 1.23
Boolean | Bool | false => False
Table | List | {1,2} => [1,2]
Additionally, any of the Haskell types from the table above can be
wrapped in a Maybe:
42 => Just 42 :: Maybe Integer nil => Nothing :: Maybe Integer
Note that Redis imposes some limitations on the possible conversions:
- Lua numbers can only be converted to Integers. Only Lua strings can be interpreted as Doubles.
- Associative Lua tables can not be converted at all. Returned tables must be "arrays", i.e. indexed only by integers.
The Redis Scripting website (http://redis.io/commands/eval) documents the exact semantics of the scripting commands and value conversion.
Hooks
A collection of hook functions used by a connection.
Constructors
| Hooks | |
Fields | |
type SendRequestHook = ([ByteString] -> IO Reply) -> [ByteString] -> IO Reply Source #
A hook for sending commands to the server and receiving replies from the server.
This wraps the command-level request path used by most Redis commands.
type SendPubSubHook = ([ByteString] -> IO ()) -> [ByteString] -> IO () Source #
A hook for sending pub/sub messages to the server.
type CallbackHook = (Message -> IO PubSub) -> Message -> IO PubSub Source #
A hook for invoking callbacks with pub/sub messages.
type SendHook = (ByteString -> IO ()) -> ByteString -> IO () Source #
A hook for sending raw bytes to the server.
This sits below request rendering and can be used to observe the exact wire payload sent on the socket.
defaultHooks :: Hooks Source #
The default hooks.
Every hook is the identity function, so installing defaultHooks has no
effect on behavior.
Low-Level Command API
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(EitherReplyByteString) debugObject key =sendRequest["DEBUG", "OBJECT", key]
Low-level representation of replies from the Redis server.
Constructors
| SingleLine ByteString | |
| Error ByteString | |
| Integer Integer | |
| Bulk (Maybe ByteString) | |
| MultiBulk (Maybe [Reply]) |
Instances
Constructors
| Ok | |
| Pong | |
| Status ByteString |
Instances
| NFData Status Source # | |||||
Defined in Database.Redis.Types | |||||
| Generic Status Source # | |||||
Defined in Database.Redis.Types Associated Types
| |||||
| Show Status Source # | |||||
| Eq Status Source # | |||||
| RedisResult Status Source # | |||||
| type Rep Status Source # | |||||
Defined in Database.Redis.Types type Rep Status = D1 ('MetaData "Status" "Database.Redis.Types" "hedis-0.16.2-inplace" '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 RedisArg a where Source #
Methods
encode :: a -> ByteString Source #
Instances
| RedisArg ByteString Source # | |
Defined in Database.Redis.Types Methods encode :: ByteString -> ByteString Source # | |
| RedisArg Int64 Source # | |
Defined in Database.Redis.Types Methods encode :: Int64 -> ByteString Source # | |
| RedisArg BitposType Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: BitposType -> ByteString Source # | |
| RedisArg ClusterSlotStatsMetric Source # | |
Defined in Database.Redis.ManualCommands Methods | |
| RedisArg Condition Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: Condition -> ByteString Source # | |
| RedisArg Cursor Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: Cursor -> ByteString Source # | |
| RedisArg DebugMode Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: DebugMode -> ByteString Source # | |
| RedisArg ExpireOpts Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: ExpireOpts -> ByteString Source # | |
| RedisArg FlushOpts Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: FlushOpts -> ByteString Source # | |
| RedisArg FunctionRestorePolicy Source # | |
Defined in Database.Redis.ManualCommands Methods | |
| RedisArg GeoOrder Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: GeoOrder -> ByteString Source # | |
| RedisArg GeoUnit Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: GeoUnit -> ByteString Source # | |
| RedisArg HSetExCondition Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: HSetExCondition -> ByteString Source # | |
| RedisArg HotkeysMetric Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: HotkeysMetric -> ByteString Source # | |
| RedisArg ListDirection Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: ListDirection -> ByteString Source # | |
| RedisArg ReplyMode Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: ReplyMode -> ByteString Source # | |
| RedisArg SizeCondition Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: SizeCondition -> ByteString Source # | |
| RedisArg VAddQuantization Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: VAddQuantization -> ByteString Source # | |
| RedisArg VQuantization Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: VQuantization -> ByteString Source # | |
| RedisArg XNackMode Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: XNackMode -> ByteString Source # | |
| RedisArg XRefPolicy Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: XRefPolicy -> ByteString Source # | |
| RedisArg ZPopMinMax Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: ZPopMinMax -> ByteString Source # | |
| RedisArg FTIndexAllMode Source # | |
Defined in Database.Redis.ManualCommands.FT Methods encode :: FTIndexAllMode -> ByteString Source # | |
| RedisArg FTOn Source # | |
Defined in Database.Redis.ManualCommands.FT Methods encode :: FTOn -> ByteString Source # | |
| RedisArg FTProfileQueryType Source # | |
Defined in Database.Redis.ManualCommands.FT Methods | |
| RedisArg JSONSetCondition Source # | |
Defined in Database.Redis.ManualCommands.JSON Methods encode :: JSONSetCondition -> ByteString Source # | |
| RedisArg JSONSetFPHA Source # | |
Defined in Database.Redis.ManualCommands.JSON Methods encode :: JSONSetFPHA -> ByteString Source # | |
| RedisArg TsAggregator Source # | |
Defined in Database.Redis.ManualCommands.Ts Methods encode :: TsAggregator -> ByteString Source # | |
| RedisArg TsAggregators Source # | |
Defined in Database.Redis.ManualCommands.Ts Methods encode :: TsAggregators -> ByteString Source # | |
| RedisArg TsBucketTimestamp Source # | |
Defined in Database.Redis.ManualCommands.Ts Methods encode :: TsBucketTimestamp -> ByteString Source # | |
| RedisArg TsDuplicatePolicy Source # | |
Defined in Database.Redis.ManualCommands.Ts Methods encode :: TsDuplicatePolicy -> ByteString Source # | |
| RedisArg TsEncoding Source # | |
Defined in Database.Redis.ManualCommands.Ts Methods encode :: TsEncoding -> ByteString Source # | |
| RedisArg Integer Source # | |
Defined in Database.Redis.Types Methods encode :: Integer -> ByteString Source # | |
| RedisArg Double Source # | |
Defined in Database.Redis.Types Methods encode :: Double -> ByteString Source # | |
| RedisArg a => RedisArg (RangeLex a) Source # | |
Defined in Database.Redis.ManualCommands Methods encode :: RangeLex a -> ByteString Source # | |
class RedisResult a where Source #
Instances
| RedisResult ByteString Source # | |
Defined in Database.Redis.Types | |
| RedisResult Int64 Source # | |
| RedisResult CommandInfo Source # | |
Defined in Database.Redis.Cluster.Command | |
| RedisResult ARIndexValuePairsResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ARInfoResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ClusterInfoResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ClusterMigrationStatusResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ClusterMigrationTask Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ClusterNodesResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ClusterSlotStatsResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ClusterSlotStatsResponseEntry Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ClusterSlotsNode Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ClusterSlotsResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ClusterSlotsResponseEntry Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult Cursor Source # | |
| RedisResult GeoCoordinates Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult GeoLocation Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult HashFieldExpirationInfo Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult HashFieldExpirationStatus Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult HotkeysGetResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult HotkeysSlotRange Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult Slowlog Source # | |
| RedisResult StreamsRecord Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult VEmbRawResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult VInfoResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult VLinksResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult VLinksWithScoresResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult VQuantization Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult VSimWithAttribsResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult VSimWithAttribsResult Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult XEntryDeletionResult Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult XInfoConsumersResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult XInfoGroupsResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult XInfoStreamResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult XPendingDetailRecord Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult XPendingSummaryResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult XReadResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult ZPopResponse Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult BFInfo Source # | |
| RedisResult CFInfo Source # | |
| RedisResult CFInsertResult Source # | |
Defined in Database.Redis.ManualCommands.CF | |
| RedisResult CMSInfo Source # | |
| RedisResult TDigestInfo Source # | |
Defined in Database.Redis.ManualCommands.Tdigest | |
| RedisResult TopkInfo Source # | |
| RedisResult TsSample Source # | |
| RedisResult WaitAofResult Source # | |
Defined in Database.Redis.ManualCommands.Wait | |
| RedisResult Reply Source # | |
| RedisResult RedisType Source # | |
| RedisResult Status Source # | |
| RedisResult Integer Source # | |
| RedisResult Bool Source # | |
| RedisResult Double Source # | |
| RedisResult a => RedisResult (XAutoclaimResult a) Source # | |
Defined in Database.Redis.ManualCommands | |
| RedisResult a => RedisResult (Maybe a) Source # | |
| (RedisResult k, RedisResult v) => RedisResult [(k, v)] Source # | |
| RedisResult a => RedisResult [a] Source # | |
| (RedisResult a, RedisResult b) => RedisResult (a, b) Source # | |
| (RedisResult a, RedisResult b, RedisResult c) => RedisResult (a, b, c) Source # | |
data ConnectionLostException Source #
Constructors
| ConnectionLost |
Instances
| Exception ConnectionLostException Source # | |
| Show ConnectionLostException Source # | |
Defined in Database.Redis.ConnectionContext Methods showsPrec :: Int -> ConnectionLostException -> ShowS # show :: ConnectionLostException -> String # showList :: [ConnectionLostException] -> ShowS # | |
newtype ConnectTimeout Source #
Constructors
| ConnectTimeout ConnectPhase |
Instances
| Exception ConnectTimeout Source # | |
Defined in Database.Redis.ConnectionContext Methods toException :: ConnectTimeout -> SomeException # fromException :: SomeException -> Maybe ConnectTimeout # displayException :: ConnectTimeout -> String # backtraceDesired :: ConnectTimeout -> Bool # | |
| Show ConnectTimeout Source # | |
Defined in Database.Redis.ConnectionContext Methods showsPrec :: Int -> ConnectTimeout -> ShowS # show :: ConnectTimeout -> String # showList :: [ConnectTimeout] -> ShowS # | |
Instances
| Enum HashSlot Source # | |
Defined in Database.Redis.Cluster.HashSlot | |
| Num HashSlot Source # | |
Defined in Database.Redis.Cluster.HashSlot | |
| Integral HashSlot Source # | |
Defined in Database.Redis.Cluster.HashSlot | |
| Real HashSlot Source # | |
Defined in Database.Redis.Cluster.HashSlot Methods toRational :: HashSlot -> Rational # | |
| Show HashSlot Source # | |
| Eq HashSlot Source # | |
| Ord HashSlot Source # | |
Defined in Database.Redis.Cluster.HashSlot | |
keyToSlot :: ByteString -> HashSlot Source #
Compute the hashslot associated with a key
>>>keyToSlot "123"HashSlot 5970>>>keyToSlot "{123"HashSlot 2872>>>keyToSlot "{123}"HashSlot 5970>>>keyToSlot "{}123"HashSlot 7640>>>keyToSlot "{123}1{abc}"HashSlot 5970>>>keyToSlot "\00\01"HashSlot 4129