hedis
Safe HaskellNone
LanguageHaskell2010

Database.Redis

Synopsis

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 <- checkedConnect ci

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:

disconnect conn

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

Instances details
Show ConnectInfo Source # 
Instance details

Defined in Database.Redis.Connection

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 ConnectInfo from a URL according to the Rules in Redis client

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

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.

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 :: (RedisCtx m f) => ByteString -> m (f ByteString)

Here is how to interpret this type signature:

  • The argument types are independent of the execution context. echo always takes a ByteString parameter, 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 f of this container depends on the commands execution context m. The ByteString return type in the example is specific to the echo command. For other commands, it will often be another type.
  • In the "normal" context Redis, outside of any transactions, results are wrapped in an Either Reply.
  • Inside a transaction, in the RedisTx context, results are wrapped in a Queued.

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:

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:

runRedis conn $ do
  set "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:

runRedis conn $ 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 return Left the Reply. 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 of runRedis.
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 ping command directly after connecting or use the checkedConnect function 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.

Pub/Sub

hedis supports Redis Pub/Sub. See Database.Redis.PubSub for more information.

Advanced Usage

The Redis Monad

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
MonadIO Redis Source # 
Instance details

Defined in Database.Redis.Core.Internal

Methods

liftIO :: IO a -> Redis a #

MonadCatch Redis Source # 
Instance details

Defined in Database.Redis.Core.Internal

Methods

catch :: (HasCallStack, Exception e) => Redis a -> (e -> Redis a) -> Redis a #

MonadMask Redis Source # 
Instance details

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

Defined in Database.Redis.Core.Internal

Methods

throwM :: (HasCallStack, Exception e) => e -> 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 #

Functor Redis Source # 
Instance details

Defined in Database.Redis.Core.Internal

Methods

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

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

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 #

MonadFail Redis Source # 
Instance details

Defined in Database.Redis.Core.Internal

Methods

fail :: String -> Redis a #

MonadRedis Redis Source # 
Instance details

Defined in Database.Redis.Core

Methods

liftRedis :: Redis a -> Redis a Source #

MonadUnliftIO Redis Source # 
Instance details

Defined in Database.Redis.Core.Internal

Methods

withRunInIO :: ((forall a. Redis a -> IO a) -> IO b) -> Redis b #

RedisCtx Redis (Either Reply) Source # 
Instance details

Defined in Database.Redis.Core

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.

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.

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

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

class Monad m => MonadRedis (m :: Type -> Type) 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 #

(MonadTrans t, MonadRedis m, Monad (t m)) => MonadRedis (t m) Source # 
Instance details

Defined in Database.Redis.Core

Methods

liftRedis :: Redis a -> t m a Source #

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

data Hooks Source #

A collection of hook functions used by a connection.

Instances

Instances details
Show Hooks Source # 
Instance details

Defined in Database.Redis.Hooks

Methods

showsPrec :: Int -> Hooks -> ShowS #

show :: Hooks -> String #

showList :: [Hooks] -> ShowS #

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.

type ReceiveHook = IO Reply -> IO Reply Source #

A hook for receiving replies from the server.

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 (Either Reply ByteString)
debugObject key = sendRequest ["DEBUG", "OBJECT", key]

data Reply Source #

Low-level representation of replies from the Redis server.

Instances

Instances details
NFData Reply Source # 
Instance details

Defined in Database.Redis.Protocol

Methods

rnf :: Reply -> () #

Generic Reply Source # 
Instance details

Defined in Database.Redis.Protocol

Methods

from :: Reply -> Rep Reply x #

to :: Rep Reply x -> Reply #

Show Reply Source # 
Instance details

Defined in Database.Redis.Protocol

Methods

showsPrec :: Int -> Reply -> ShowS #

show :: Reply -> String #

showList :: [Reply] -> ShowS #

Eq Reply Source # 
Instance details

Defined in Database.Redis.Protocol

Methods

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

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

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

Constructors

Ok 
Pong 
Status ByteString 

Instances

Instances details
NFData Status Source # 
Instance details

Defined in Database.Redis.Types

Methods

rnf :: Status -> () #

Generic Status Source # 
Instance details

Defined in Database.Redis.Types

Associated Types

type Rep Status 
Instance details

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

Methods

from :: Status -> Rep Status x #

to :: Rep Status x -> Status #

Show Status Source # 
Instance details

Defined in Database.Redis.Types

Eq Status Source # 
Instance details

Defined in Database.Redis.Types

Methods

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

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

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

Instances details
RedisArg ByteString Source # 
Instance details

Defined in Database.Redis.Types

RedisArg Int64 Source # 
Instance details

Defined in Database.Redis.Types

RedisArg BitposType Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg ClusterSlotStatsMetric Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg Condition Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg Cursor Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg DebugMode Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg ExpireOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg FlushOpts Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg FunctionRestorePolicy Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg GeoOrder Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg GeoUnit Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg HSetExCondition Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg HotkeysMetric Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg ListDirection Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg ReplyMode Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg SizeCondition Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg VAddQuantization Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg VQuantization Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg XNackMode Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg XRefPolicy Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg ZPopMinMax Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisArg FTIndexAllMode Source # 
Instance details

Defined in Database.Redis.ManualCommands.FT

RedisArg FTOn Source # 
Instance details

Defined in Database.Redis.ManualCommands.FT

RedisArg FTProfileQueryType Source # 
Instance details

Defined in Database.Redis.ManualCommands.FT

RedisArg JSONSetCondition Source # 
Instance details

Defined in Database.Redis.ManualCommands.JSON

RedisArg JSONSetFPHA Source # 
Instance details

Defined in Database.Redis.ManualCommands.JSON

RedisArg TsAggregator Source # 
Instance details

Defined in Database.Redis.ManualCommands.Ts

RedisArg TsAggregators Source # 
Instance details

Defined in Database.Redis.ManualCommands.Ts

RedisArg TsBucketTimestamp Source # 
Instance details

Defined in Database.Redis.ManualCommands.Ts

RedisArg TsDuplicatePolicy Source # 
Instance details

Defined in Database.Redis.ManualCommands.Ts

RedisArg TsEncoding Source # 
Instance details

Defined in Database.Redis.ManualCommands.Ts

RedisArg Integer Source # 
Instance details

Defined in Database.Redis.Types

RedisArg Double Source # 
Instance details

Defined in Database.Redis.Types

RedisArg a => RedisArg (RangeLex a) Source # 
Instance details

Defined in Database.Redis.ManualCommands

class RedisResult a where Source #

Methods

decode :: Reply -> Either Reply a Source #

Instances

Instances details
RedisResult ByteString Source # 
Instance details

Defined in Database.Redis.Types

RedisResult Int64 Source # 
Instance details

Defined in Database.Redis.Types

RedisResult CommandInfo Source # 
Instance details

Defined in Database.Redis.Cluster.Command

RedisResult ARIndexValuePairsResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult ARInfoResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult ClusterInfoResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult ClusterMigrationStatusResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult ClusterMigrationTask Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult ClusterNodesResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult ClusterSlotStatsResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult ClusterSlotStatsResponseEntry 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 ClusterSlotsResponseEntry Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult Cursor Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult GeoCoordinates Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult GeoLocation Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult HashFieldExpirationInfo Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult HashFieldExpirationStatus Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult HotkeysGetResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult HotkeysSlotRange Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult Slowlog Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult StreamsRecord Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult VEmbRawResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult VInfoResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult VLinksResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult VLinksWithScoresResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult VQuantization Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult VSimWithAttribsResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult VSimWithAttribsResult Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult XEntryDeletionResult Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult XInfoConsumersResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult XInfoGroupsResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult XInfoStreamResponse 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 ZPopResponse Source # 
Instance details

Defined in Database.Redis.ManualCommands

RedisResult BFInfo Source # 
Instance details

Defined in Database.Redis.ManualCommands.BF

RedisResult CFInfo Source # 
Instance details

Defined in Database.Redis.ManualCommands.CF

RedisResult CFInsertResult Source # 
Instance details

Defined in Database.Redis.ManualCommands.CF

RedisResult CMSInfo Source # 
Instance details

Defined in Database.Redis.ManualCommands.Cms

RedisResult TDigestInfo Source # 
Instance details

Defined in Database.Redis.ManualCommands.Tdigest

RedisResult TopkInfo Source # 
Instance details

Defined in Database.Redis.ManualCommands.Topk

RedisResult TsSample Source # 
Instance details

Defined in Database.Redis.ManualCommands.Ts

RedisResult WaitAofResult Source # 
Instance details

Defined in Database.Redis.ManualCommands.Wait

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 Integer Source # 
Instance details

Defined in Database.Redis.Types

RedisResult Bool Source # 
Instance details

Defined in Database.Redis.Types

RedisResult Double Source # 
Instance details

Defined in Database.Redis.Types

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

Defined in Database.Redis.ManualCommands

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

Defined in Database.Redis.Types

Methods

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

(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 b) => RedisResult (a, b) Source # 
Instance details

Defined in Database.Redis.Types

Methods

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

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

Defined in Database.Redis.Types

Methods

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

data HashSlot Source #

Instances

Instances details
Enum HashSlot Source # 
Instance details

Defined in Database.Redis.Cluster.HashSlot

Num HashSlot Source # 
Instance details

Defined in Database.Redis.Cluster.HashSlot

Integral 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

Eq HashSlot Source # 
Instance details

Defined in Database.Redis.Cluster.HashSlot

Ord HashSlot Source # 
Instance details

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