HORIZON HASKELLDocslts/ghc-9.14.x45dd5372026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · 45dd537 · 2026-10-11

Modulehedis-0.16.4Haskell2010

Database.Redis.Sentinel

Database.Redis like interface with connection through Redis Sentinel.

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

Example:

conn <- connect SentinelConnectionInfo (("localhost", 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

  • 229 types
  • 4 classes
  • 737 values
  • Packagehedis-0.16.4
  • Exports970
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceSentinel.hs

Connection

3 declarations

runRedis with Sentinel support

2 declarations

Re-export Database.Redis

965 declarations

Compute the hashslot associated with a key

Example6 expressions
keyToSlot "123"HashSlot 5970keyToSlot "{123"HashSlot 2872keyToSlot "{123}"HashSlot 5970keyToSlot "{}123"HashSlot 7640keyToSlot "{123}1{abc}"HashSlot 5970keyToSlot "\00\01"HashSlot 4129
valuebgsaveSchedule :: RedisCtx m f => m (f Status)
#

Asynchronously save the dataset to disk (http://redis.io/commands/bgsave).

Immediately returns OK when an AOF rewrite is in progress and schedule the background save to run at the next opportunity.

A client may bee able to check if the operation succeeded using the lastsave command

Since Redis 3.2.2

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
valuedisconnect :: Connection -> IO ()
#

Destroy all idle resources in the pool, works for all types of the connection.

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

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]
valueunRedis :: Redis a -> ReaderT RedisEnv IO a
#

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.

valueargrepWithValuesOpts
  1. :: RedisCtx m f
  2. => ByteString

    Array key.

  3. -> ByteString

    Start index or - for the first array index.

  4. -> ByteString

    End index or + for the last array index.

  5. -> NonEmpty ARGrepPredicate

    One or more predicates to apply.

  6. -> ARGrepOpts

    Additional predicate options.

  7. -> m (f ARIndexValuePairsResponse)
#

Searches array elements in a range and returns matching index-value pairs (https://redis.io/commands/argrep).

O(P * C) where P is the number of visited positions and C is the cost of evaluating predicates.

Since Redis 8.8.0

valuearseek
  1. :: RedisCtx m f
  2. => ByteString

    Array key.

  3. -> Integer

    The new insert cursor position.

  4. -> m (f Bool)
#

Sets the ARINSERT ARRING cursor to a specific index (<https:redis.iocommands/arseek>).

O(1)

Since Redis 8.8.0

valueauth
  1. :: RedisCtx m f
  2. => ByteString

    Password.

  3. -> m (f Status)
#

O(N) where N is the number of passwords defined for the user.

Authenticates client to the server.

valueauthOpts
  1. :: RedisCtx m f
  2. => ByteString

    Password.

  3. -> AuthOpts

    Additional options.

  4. -> m (f Status)
#

O(N) where N is the number of passwords defined for the user.

Authenticates client to the server.

This method allows passing additional options.

valueblmove
  1. :: RedisCtx m f
  2. => ByteString

    Source

  3. -> ByteString

    Destination

  4. -> ListDirection

    Direction where to get the element from in the source list

  5. -> ListDirection

    Direction where to push the element to in the destination list

  6. -> Integer
  7. -> m (f (Maybe ByteString))
#

Move an element after taking it from one list and pushing it to another, or blocks until one is available (https://redis.io/commands/blmove).

In clustered environments source and destination keys must be in the same hash slot, which can be ensured by using hash tags (e.g. {tag}source and {tag}destination).

O(1)

Since Redis 6.2.0

Removes and returns member-score pairs from the first non-empty sorted set from a list of keys, or blocks until one is available (https://redis.io/commands/bzmpop).

O(K) + O(Mlog(N)) where K is the number of provided keys, N is the number of elements in the sorted set, and M is the number of elements popped.

In clustered environment, commands must operate on keys within the same hash slot.

Since Redis 7.0.0

Removes and returns member-score pairs from the first non-empty sorted set from a list of keys, or blocks until one is available (https://redis.io/commands/bzmpop).

O(K) + O(Mlog(N)) where K is the number of provided keys, N is the number of elements in the sorted set, and M is the number of elements popped.

In clustered environment, commands must operate on keys within the same hash slot.

Since Redis 7.0.0

valueclientNoTouch :: RedisCtx m f => Bool -> m (f Status)
#

The CLIENT NO-TOUCH command controls whether commands sent by the client will alter the LRULFU of the keys they access (<https:redis.iocommands/client-notouch>).

When turned on, the current client will not change LFU/LRU stats, unless it sends the TOUCH command.

When turned off, the client touches LFU/LRU stats just as a normal client.

O(1)

Since Redis 7.2.0

valuecommandListOpts
  1. :: RedisCtx m f
  2. => Maybe CommandListFilter

    Optional filtering mode.

    CommandListFilterByModule keeps only commands that belong to the given module. CommandListFilterByAclCat keeps only commands from the given ACL category. CommandListFilterByPattern keeps only commands whose names match the specified glob-style pattern.

  3. -> m (f [ByteString])
#

Returns a list of command names (https://redis.io/commands/command-list).

O(N) where N is the total number of Redis commands.

Since Redis 7.0.0

Default options for AuthOpts

Example1 expression
defaultAuthOptsAuthOpts {authOptsUsername = Nothing}

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
    , migrateAuth = Nothing
    }

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

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
    }

Redis default XReadOpts. Equivalent to omitting all optional parameters.

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

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
  , zaddSizeCondition = Nothing -- omit GT and LT options
  }
valuedelex
  1. :: RedisCtx m f
  2. => ByteString

    Key of the string.

  3. -> m (f Bool)
#

Conditionally removes the specified key based on value or hash digest comparison (https://redis.io/commands/delex).

O(1) for IFEQ and IFNE. O(N) for IFDEQ and IFDNE, where N is the length of the string value.

Since Redis 8.4.0

valuedelexWhen
  1. :: RedisCtx m f
  2. => ByteString

    Key of the string.

  3. -> DelexCondition

    Condition to enforce.

    The DELEX command supports a set of options that modify its behavior. Only one option can be specified: IFEQ removes the key if the value is equal to the specified value. IFNE removes the key if the value is not equal to the specified value. IFDEQ removes the key if its hash digest is equal to the specified hash digest. IFDNE removes the key if its hash digest is not equal to the specified hash digest.

  4. -> m (f Bool)
#

Conditionally removes the specified key based on value or hash digest comparison (https://redis.io/commands/delex).

O(1) for IFEQ and IFNE. O(N) for IFDEQ and IFDNE, where N is the length of the string value.

Since Redis 8.4.0

valueevalsha
  1. :: (RedisCtx m f, RedisResult a)
  2. => ByteString

    base16-encoded sha1 hash of the script

  3. -> [ByteString]

    keys

  4. -> [ByteString]

    args

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

valuehexpire
  1. :: RedisCtx m f
  2. => ByteString

    Key of the hash.

  3. -> Integer

    Seconds until expiration.

  4. -> NonEmpty ByteString

    List of fields to set expiration for.

  5. -> m (f [HashFieldExpirationStatus])
#

Sets expiration for hash fields using relative time to expire in seconds (https://redis.io/commands/hexpire).

O(N) where N is the number of specified fields.

Set an expiration (TTL or time to live) on one or more fields of a given hash key. You must specify at least one field. Field(s) will automatically be deleted from the hash key when their TTLs expire.

Field expirations will only be cleared by commands that delete or overwrite the contents of the hash fields, including HDEL and HSET commands. This means that all the operations that conceptually alter the value stored at a hash key's field without replacing it with a new one will leave the TTL untouched.

You can clear the TTL using the hpersist command, which turns the hash field back into a persistent field.

Note that calling hexpirehpexpire with a zero TTL or hexpireathpexpireat with a time in the past will result in the hash field being deleted.

Since Redis 7.4.0

valuehrandfieldCount
  1. :: RedisCtx m f
  2. => ByteString
  3. -> Integer
  4. -> m (f [ByteString])
#

Returns one or more random fields from a hash (https://redis.io/commands/hrandfield).

O(N) where N is the number of fields returned.

If the provided count argument is positive, return an array of distinct fields. The array's length is either count or the hash's number of fields (HLEN), whichever is lower.

If called with a negative count, the behavior changes and the command is allowed to return the same field multiple times. In this case, the number of returned fields is the absolute value of the specified count.

Since Redis 6.2.0

Returns one or more random fields and their values from a hash (https://redis.io/commands/hrandfield).

O(N) where N is the number of fields returned.

If the provided count argument is positive, return an array of distinct fields. The array's length is either count or the hash's number of fields (HLEN), whichever is lower.

If called with a negative count, the behavior changes and the command is allowed to return the same field multiple times. In this case, the number of returned fields is the absolute value of the specified count.

Since Redis 6.2.0

valueincrexOpts
  1. :: RedisCtx m f
  2. => ByteString

    The name of the key to increment.

  3. -> IncrexOpts Integer

    Bound and expiration options.

    LBOUND and UBOUND constrain the result. SATURATE clips out-of-bounds values instead of rejecting the increment. EXPXEXATPXATPERSIST control the key expiration. ENX only sets the expiration when the key currently has no TTL.

  4. -> m (f (Integer, Integer))
#

Increments the numeric value of a key by one and optionally updates its expiration (https://redis.io/commands/increx).

O(1)

Since Redis 8.8.0

valuelmove
  1. :: RedisCtx m f
  2. => ByteString

    Source

  3. -> ByteString

    Destination

  4. -> ListDirection

    Direction where to get the element from in the source list

  5. -> ListDirection

    Direction where to push the element to in the destination list

  6. -> m (f (Maybe ByteString))
#

Move an element after taking it from one list and pushing it to another (https://redis.io/commands/lmove).

In clustered environments source and destination keys must be in the same hash slot, which can be ensured by using hash tags (e.g. {tag}source and {tag}destination). O(1)

Since Redis 6.2.0

valuelpos :: RedisCtx m f => ByteString -> ByteString -> m (f (Maybe Integer))
#

Returns the index of the first matching element in a list (https://redis.io/commands/lpos).

O(N) where N is the number of elements in the list, for the average case. When searching for elements near the head or the tail of the list, or when the MAXLEN option is provided, the command may run in constant time.

Since Redis 6.0.6

valuemsetexOpts
  1. :: RedisCtx m f
  2. => NonEmpty (ByteString, ByteString)

    A series of key/value pairs.

  3. -> SetOpts

    Shared condition and expiration flags.

    The MSETEX command supports a set of options that modify its behavior: NX sets the keys and their expiration time only if none of the specified keys exist. XX sets the keys and their expiration time only if all of the specified keys already exist. EXPXEXAT/PXAT set the shared expiration for the specified keys. KEEPTTL retains the time to live associated with the keys.

  4. -> m (f Bool)
#

Atomically sets multiple string keys with an optional shared expiration in a single operation (https://redis.io/commands/msetex).

O(N) where N is the number of keys to set.

Since Redis 8.4.0

valuevadd
  1. :: RedisCtx m f
  2. => ByteString

    The name of the key that will hold the vector set data.

  3. -> NonEmpty Double

    The vector values as floating point numbers.

    This uses the VALUES argument form and automatically supplies the number of vector elements.

  4. -> ByteString

    The name of the element that is being added to the vector set.

  5. -> m (f Bool)
#

Adds a new element to a vector set, or updates its vector if it already exists (https://redis.io/commands/vadd).

O(log(N)) for each element added, where N is the number of elements in the vector set.

Since Redis 8.0.0

valuevaddOpts
  1. :: RedisCtx m f
  2. => ByteString

    The name of the key that will hold the vector set data.

  3. -> NonEmpty Double

    The vector values as floating point numbers.

  4. -> ByteString

    The name of the element that is being added to the vector set.

  5. -> VAddOpts

    Additional parameters.

    `REDUCE dim` reduces the dimensionality of the vector using random projection. CAS performs the slow neighbor candidate collection in the background. NOQUANT, Q8, and BIN control quantization and are mutually exclusive. EF sets the build exploration factor. SETATTR associates attributes with the entry. M sets the maximum number of graph links per node.

  6. -> m (f Bool)
#

Adds a new element to a vector set, or updates its vector if it already exists (https://redis.io/commands/vadd).

O(log(N)) for each element added, where N is the number of elements in the vector set.

Since Redis 8.0.0

valuevrange
  1. :: RedisCtx m f
  2. => ByteString

    The name of the vector set key from which to retrieve elements.

  3. -> ByteString

    The starting point of the lexicographical range.

    Use a value prefixed with `[` for an inclusive bound, a value prefixed with `(` for an exclusive bound, or - for the minimum element.

  4. -> ByteString

    The ending point of the lexicographical range.

    Use a value prefixed with `[` for an inclusive bound, a value prefixed with `(` for an exclusive bound, or + for the maximum element.

  5. -> m (f [ByteString])
#

Returns elements in a lexicographical range (https://redis.io/commands/vrange).

O(log(K)+M) where K is the number of elements in the start prefix, and M is the number of elements returned. In practical terms, the command is just O(M).

Since Redis 8.4.0

valuevrangeCount
  1. :: RedisCtx m f
  2. => ByteString

    The name of the vector set key from which to retrieve elements.

  3. -> ByteString

    The starting point of the lexicographical range.

  4. -> ByteString

    The ending point of the lexicographical range.

  5. -> Integer

    The maximum number of elements to return.

    If count is negative, the command returns all elements in the specified range.

  6. -> m (f [ByteString])
#

Returns elements in a lexicographical range (https://redis.io/commands/vrange).

O(log(K)+M) where K is the number of elements in the start prefix, and M is the number of elements returned. In practical terms, the command is just O(M).

Since Redis 8.4.0

valuevrem
  1. :: RedisCtx m f
  2. => ByteString

    The name of the key that holds the vector set.

  3. -> ByteString

    The name of the element to remove from the vector set.

  4. -> m (f Bool)
#

Remove an element from a vector set (https://redis.io/commands/vrem).

O(log(N)) for each element removed, where N is the number of elements in the vector set.

Since Redis 8.0.0

valuevsimOpts
  1. :: RedisCtx m f
  2. => ByteString

    The name of the key that holds the vector set data.

  3. -> VSimQuery

    Query vector source.

  4. -> VSimOpts

    Additional search options.

    COUNT limits the number of returned results. EPSILON filters out elements that are too far from the query vector. EF controls the exploration factor. FILTER applies a filtering expression and `FILTER-EF` limits filtering effort. TRUTH forces an exact linear scan. NOTHREAD executes the search in the main thread.

  5. -> m (f [ByteString])
#

Return elements similar to a given vector or element (https://redis.io/commands/vsim).

O(log(N)) where N is the number of elements in the vector set.

Since Redis 8.0.0

valuexautoclaim
  1. :: RedisCtx m f
  2. => ByteString

    Stream name.

  3. -> ByteString

    Consumer group name.

  4. -> ByteString

    Consumer name.

  5. -> Integer

    Min idle time (ms).

  6. -> ByteString

    ID of the message to start.

  7. -> m (f XAutoclaimStreamsResult)
#

O(1) Transfers ownership of pending stream entries that match the specified criteria. The message should be pending for more than <min-idle-time> milliseconds and ID should be greater than <start>.

XAUTOCLAIM <stream name> <consumer group name> <min idle time> <start>

This version of function claims no more than 100 mesages, use xautoclaimOpt to override this behavior.

Since Redis 7.0: fails on ealier versions.

valuexautoclaimJustIds
  1. :: RedisCtx m f
  2. => ByteString

    Stream name.

  3. -> ByteString

    Consumer group name.

  4. -> ByteString

    Consumer name.

  5. -> Integer

    Min idle time (ms).

  6. -> ByteString

    start ID.

  7. -> m (f XAutoclaimJustIdsResult)
#

O(1) Transfers ownership of pending stream entries that match the specified criteria. See xautoclaim for more details about criteria.

This variant returns only id of the messages without data. This method claims no more than 100 messages, see xautoclaimJustIdsOpts for changing this default.

XAUTOCLAIM <stream name> <consumer group name> <min idle time> <start> JUSTID

Since Redis 7.0: fails on the ealier versions.

valuexautoclaimJustIdsOpts
  1. :: RedisCtx m f
  2. => ByteString

    Stream name.

  3. -> ByteString

    Consumers group name.

  4. -> ByteString

    Consumer namee.

  5. -> Integer

    min idle time (ms).

  6. -> ByteString

    Start ID.

  7. -> XAutoclaimOpts

    Additional parametres.

  8. -> m (f XAutoclaimJustIdsResult)
#

O(1) if count is small Transfers ownership of pending stream entries that match the specified criteria. See xautoclaim for more details about criteria.

This variant returns only id of the messages without data and allows to set the maximum number of messages to be claimed.

XAUTOCLAIM <stream name> <consumer group name> <min idle time> <start> COUNT <count> JUSTID

Since Redis 7.0: fails on the ealier versions.

valuexautoclaimOpts
  1. :: RedisCtx m f
  2. => ByteString

    Stream name.

  3. -> ByteString

    Consumer group name.

  4. -> ByteString

    Consumer name.

  5. -> Integer

    min idle time (ms).

  6. -> ByteString

    start ID.

  7. -> XAutoclaimOpts

    Additional parameters.

  8. -> m (f XAutoclaimStreamsResult)
#

O(1) if count is small. Transfers ownership of pending stream entries that match the specified criteria. See xautoclaim for details.

Allows to pass additional optional parameters to set limit.

XAUTOCLAIM <stream name> <consumer group name> <min idle time> <start> COUNT <count>

Since Redis 7.0: fails on the ealier versions.

valuezdiff :: RedisCtx m f => NonEmpty ByteString -> m (f [ByteString])
#

Returns the difference between multiple sorted sets (https://redis.io/commands/zdiff).

O(L + (N - K)log(N)) worst case where $L$ is the total number of elements in all the sorted sets, N is the size of the first sorted set, and K is the size of the result set.

In clustered environment, commands must operate on keys within the same hash slot.

Since Redis 6.2.0

valuezdiffWithscores
  1. :: RedisCtx m f
  2. => NonEmpty ByteString

    Sorted set keys.

  3. -> m (f [(ByteString, Double)])
#

Returns the difference between multiple sorted sets with scores (https://redis.io/commands/zdiff).

O(L + (N - K)log(N)) worst case where $L$ is the total number of elements in all the sorted sets, N is the size of the first sorted set, and K is the size of the result set.

In clustered environment, commands must operate on keys within the same hash slot.

Since Redis 6.2.0

valuezdiffstore
  1. :: RedisCtx m f
  2. => ByteString

    Destination key.

  3. -> NonEmpty ByteString

    Sorted set keys.

  4. -> m (f Integer)
#

Stores the difference of multiple sorted sets in a key (https://redis.io/commands/zdiffstore).

O(L + (N - K)log(N)) worst case where $L$ is the total number of elements in all the sorted sets, N is the size of the first sorted set, and K is the size of the result set.

In clustered environment, commands must operate on keys within the same hash slot.

Keys that do not exist are considered to be empty sets.

If destination already exists, it is overwritten.

Since Redis 6.2.0

valuezinter
  1. :: RedisCtx m f
  2. => NonEmpty ByteString

    Sorted set keys.

  3. -> m (f [ByteString])
#

Returns the intersection of multiple sorted sets (https://redis.io/commands/zinter).

O(NK) + O(Mlog(M)) worst case with N being the smallest input sorted set, K being the number of input sorted sets and M being the number of elements in the resulting sorted set.

In clustered environment, commands must operate on keys within the same hash slot.

Since Redis 6.2.0

valuezinterOpts
  1. :: RedisCtx m f
  2. => NonEmpty ByteString

    Sorted set keys.

  3. -> ZAggregateOpts
  4. -> m (f [ByteString])
#

Returns the intersection of multiple sorted sets (https://redis.io/commands/zinter).

O(NK) + O(Mlog(M)) worst case with N being the smallest input sorted set, K being the number of input sorted sets and M being the number of elements in the resulting sorted set.

In clustered environment, commands must operate on keys within the same hash slot.

Since Redis 6.2.0

valuezinterWithscores
  1. :: RedisCtx m f
  2. => NonEmpty ByteString

    Sorted set keys.

  3. -> m (f [(ByteString, Double)])
#

Returns the intersection of multiple sorted sets with scores (https://redis.io/commands/zinter).

O(NK) + O(Mlog(M)) worst case with N being the smallest input sorted set, K being the number of input sorted sets and M being the number of elements in the resulting sorted set.

In clustered environment, commands must operate on keys within the same hash slot.

Since Redis 6.2.0

valuezinterWithscoresOpts
  1. :: RedisCtx m f
  2. => NonEmpty ByteString

    Sorted set keys.

  3. -> ZAggregateOpts
  4. -> m (f [(ByteString, Double)])
#

Returns the intersection of multiple sorted sets with scores (https://redis.io/commands/zinter).

O(NK) + O(Mlog(M)) worst case with N being the smallest input sorted set, K being the number of input sorted sets and M being the number of elements in the resulting sorted set.

In clustered environment, commands must operate on keys within the same hash slot.

Since Redis 6.2.0

Removes and returns member-score pairs from the first non-empty sorted set from a list of keys (https://redis.io/commands/zmpop).

O(K) + O(Mlog(N)) where K is the number of provided keys, N is the number of elements in the sorted set, and M is the number of elements popped.

In clustered environment, commands must operate on keys within the same hash slot.

Since Redis 7.0.0

valuejsonArrappend
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to the array.

  4. -> NonEmpty ByteString

    Serialized JSON values to append.

  5. -> m (f Reply)
#

Appends one or more JSON values into the array at path after the last element in it (https://redis.io/commands/json.arrappend).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonArrindex
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to the array.

  4. -> ByteString

    Serialized JSON scalar to search for.

  5. -> m (f Reply)
#

Returns the index of the first occurrence of a JSON scalar value in the array at path (https://redis.io/commands/json.arrindex).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(N) when path is evaluated to a single value where N is the size of the array, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonArrindexOpts
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to the array.

  4. -> ByteString

    Serialized JSON scalar to search for.

  5. -> JSONArrIndexOpts

    Optional search range.

  6. -> m (f Reply)
#

Returns the index of the first occurrence of a JSON scalar value in the array at path (https://redis.io/commands/json.arrindex).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(N) when path is evaluated to a single value where N is the size of the array, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonArrinsert
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to the array.

  4. -> Integer

    Insertion index.

  5. -> NonEmpty ByteString

    Serialized JSON values to insert.

  6. -> m (f Reply)
#

Inserts the JSON scalar(s) value at the specified index in the array at path (https://redis.io/commands/json.arrinsert).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(N) when path is evaluated to a single value where N is the size of the array, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonArrpopAt
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to the array.

  4. -> m (f Reply)
#

Removes and returns the element at the end of the array at path (https://redis.io/commands/json.arrpop).

The reply shape depends on the path syntax and popped value type, so this wrapper returns the raw Reply.

O(1) when the popped item is the last element, otherwise O(N) where N is the size of the array

Since RedisJSON 1.0.0

valuejsonArrtrim
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to the array.

  4. -> Integer

    Start index.

  5. -> Integer

    Stop index.

  6. -> m (f Reply)
#

Trims the array at path to contain only the specified inclusive range of indices from start to stop (https://redis.io/commands/json.arrtrim).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(N) when path is evaluated to a single value where N is the size of the array, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonClear
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> m (f Integer)
#

Clears all values from an array or an object and sets numeric values at the root path to 0 (https://redis.io/commands/json.clear).

O(N) when path is evaluated to a single value where N is the size of the values, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 2.0.0

valuejsonClearAt
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to clear.

  4. -> m (f Integer)
#

Clears all values from an array or an object and sets numeric values at path to 0 (https://redis.io/commands/json.clear).

O(N) when path is evaluated to a single value where N is the size of the values, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 2.0.0

valuejsonDebugMemory
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> m (f Reply)
#

Reports the size in bytes of a key at the root path (https://redis.io/commands/json.debug-memory).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(N) when path is evaluated to a single value, where N is the size of the value, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonDel
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> m (f Integer)
#

Deletes a value at the root path (https://redis.io/commands/json.del).

O(N) when path is evaluated to a single value where N is the size of the deleted value, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonMerge
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to merge into.

  4. -> ByteString

    Serialized JSON value.

  5. -> m (f Status)
#

Merges a given JSON value into matching paths (https://redis.io/commands/json.merge).

Consequently, JSON values at matching paths are updated, deleted, or expanded with new children.

O(M+N) when path is evaluated to a single value where M is the size of the original value and N is the size of the new value, O(M+N) when path is evaluated to multiple values where M is the size of the key and N is the size of the new value times the number of matches

Since RedisJSON 2.6.0

valuejsonObjkeys
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> m (f Reply)
#

Returns the key names of JSON objects at the root path (https://redis.io/commands/json.objkeys).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(N) when path is evaluated to a single value, where N is the number of keys in the object, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonObjkeysAt
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to the object.

  4. -> m (f Reply)
#

Returns the key names of JSON objects at path (https://redis.io/commands/json.objkeys).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(N) when path is evaluated to a single value, where N is the number of keys in the object, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonObjlen
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> m (f Reply)
#

Returns the number of keys in JSON objects at the root path (https://redis.io/commands/json.objlen).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonObjlenAt
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to the object.

  4. -> m (f Reply)
#

Returns the number of keys in JSON objects at path (https://redis.io/commands/json.objlen).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonResp
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> m (f Reply)
#

Returns the JSON value at the root path in Redis Serialization Protocol (RESP) (https://redis.io/commands/json.resp).

The reply may be any RESP shape depending on the JSON value, so this wrapper returns the raw Reply.

O(N) when path is evaluated to a single value, where N is the size of the value, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonRespAt
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to inspect.

  4. -> m (f Reply)
#

Returns the JSON value at path in Redis Serialization Protocol (RESP) (https://redis.io/commands/json.resp).

The reply may be any RESP shape depending on the JSON value, so this wrapper returns the raw Reply.

O(N) when path is evaluated to a single value, where N is the size of the value, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonSetOpts
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to set.

  4. -> ByteString

    Serialized JSON value.

  5. -> JSONSetOpts

    Conditional and FPHA options.

  6. -> m (f (Maybe Status))
#

Sets or updates the JSON value at a path (https://redis.io/commands/json.set).

O(M+N) when path is evaluated to a single value where M is the size of the original value and N is the size of the new value, O(M+N) when path is evaluated to multiple values where M is the size of the key and N is the size of the new value times the number of matches

Since RedisJSON 1.0.0

valuejsonType
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> m (f Reply)
#

Returns the type of the JSON value at the root path (https://redis.io/commands/json.type).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuejsonTypeAt
  1. :: RedisCtx m f
  2. => ByteString

    Key holding a JSON value.

  3. -> ByteString

    Path to inspect.

  4. -> m (f Reply)
#

Returns the type of the JSON value at path (https://redis.io/commands/json.type).

The reply shape depends on the path syntax, so this wrapper returns the raw Reply.

O(1) when path is evaluated to a single value, O(N) when path is evaluated to multiple values, where N is the size of the key

Since RedisJSON 1.0.0

valuetsMget
  1. :: RedisCtx m f
  2. => NonEmpty ByteString

    Filter expressions.

  3. -> m (f Reply)
#

Get the sample with the highest timestamp from each time series matching a specific filter (https://redis.io/commands/ts.mget).

The reply is heterogeneous and depends on label options, so this wrapper returns the raw Reply.

O(n) where n is the number of time-series that match the filters

Since RedisTimeSeries 1.0.0

valuetsMrange
  1. :: RedisCtx m f
  2. => ByteString

    Lower timestamp bound, or -.

  3. -> ByteString

    Upper timestamp bound, or +.

  4. -> NonEmpty ByteString

    Filter expressions.

  5. -> m (f Reply)
#

Query a range across multiple time series by filters in forward direction (https://redis.io/commands/ts.mrange).

The reply is heterogeneous and may include labels or grouped output, so this wrapper returns the raw Reply.

O(n/m+k) where n is the number of data points, m is the chunk size, and k is the number of returned samples

Since RedisTimeSeries 1.0.0

valuetsMrangeOpts
  1. :: RedisCtx m f
  2. => ByteString

    Lower timestamp bound, or -.

  3. -> ByteString

    Upper timestamp bound, or +.

  4. -> NonEmpty ByteString

    Filter expressions.

  5. -> TsMRangeOpts

    Query options.

  6. -> m (f Reply)
#

Query a range across multiple time series by filters in forward direction (https://redis.io/commands/ts.mrange).

The reply is heterogeneous and may include labels or grouped output, so this wrapper returns the raw Reply.

O(n/m+k) where n is the number of data points, m is the chunk size, and k is the number of returned samples

Since RedisTimeSeries 1.0.0

valuetsMrevrange
  1. :: RedisCtx m f
  2. => ByteString

    Lower timestamp bound, or -.

  3. -> ByteString

    Upper timestamp bound, or +.

  4. -> NonEmpty ByteString

    Filter expressions.

  5. -> m (f Reply)
#

Query a range across multiple time series by filters in reverse direction (https://redis.io/commands/ts.mrevrange).

The reply is heterogeneous and may include labels or grouped output, so this wrapper returns the raw Reply.

O(n/m+k) where n is the number of data points, m is the chunk size, and k is the number of returned samples

Since RedisTimeSeries 1.4.0

valuetsMrevrangeOpts
  1. :: RedisCtx m f
  2. => ByteString

    Lower timestamp bound, or -.

  3. -> ByteString

    Upper timestamp bound, or +.

  4. -> NonEmpty ByteString

    Filter expressions.

  5. -> TsMRangeOpts

    Query options.

  6. -> m (f Reply)
#

Query a range across multiple time series by filters in reverse direction (https://redis.io/commands/ts.mrevrange).

The reply is heterogeneous and may include labels or grouped output, so this wrapper returns the raw Reply.

O(n/m+k) where n is the number of data points, m is the chunk size, and k is the number of returned samples

Since RedisTimeSeries 1.4.0

valuewait
  1. :: RedisCtx m f
  2. => Integer

    Number of replicas to wait for.

  3. -> Integer

    Maximum time to wait in milliseconds. 0 means wait forever.

  4. -> m (f Integer)
#

O(1) Wait for preceding writes to be acknowledged by a given number of replicas (https://redis.io/commands/wait).

Blocks until the asynchronous replication of all preceding write commands sent by the connection is completed.

Since Redis 3.0.0

valuewaitaof
  1. :: RedisCtx m f
  2. => Integer

    Number of local Redis instances to wait for AOF fsync on (0 or 1).

  3. -> Integer

    Number of replicas to wait for AOF fsync on.

  4. -> Integer

    Maximum time to wait in milliseconds. 0 means wait forever.

  5. -> m (f WaitAofResult)
#

O(1) Wait for preceding writes to be fsynced to the append-only file locally and/or on replicas (https://redis.io/commands/waitaof).

Blocks until all of the preceding write commands sent by the connection are written to the append-only file of the master and/or replicas.

Since Redis 7.2.0

valueaddChannels
  1. :: MonadIO m
  2. => PubSubController
  3. -> [(RedisChannel, MessageCallback)]

    the channels to subscribe to

  4. -> [(RedisPChannel, PMessageCallback)]

    the channels to pattern subscribe to

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

valueaddChannelsAndWait
  1. :: MonadIO m
  2. => PubSubController
  3. -> [(RedisChannel, MessageCallback)]

    the channels to subscribe to

  4. -> [(RedisPChannel, PMessageCallback)]

    the channels to psubscribe to

  5. -> m UnregisterCallbacksAction
#

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

Note that this function waits for requested subscription change requests, so if you for example call addChannelsAndWait from multiple threads simultaneously, they will all wait their pending subscription changes to be acknowledged by Redis.

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.

valuecurrentChannels :: FunctorMonadIO m => PubSubController -> m [RedisChannel]
#

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.

valuecurrentPChannels
  1. :: FunctorMonadIO m
  2. => PubSubController
  3. -> m [RedisPChannel]
#

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.

valuepubSub
  1. :: PubSub

    Initial subscriptions.

  2. -> (Message -> IO PubSub)

    Callback function.

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

valuepubSubForever
  1. :: Connection

    The connection pool

  2. -> PubSubController

    The controller which keeps track of all subscriptions and handlers

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

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

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 Control.Concurrent.Async.cancel to kill the thread running pubSubForever.

valuewithPubSub
  1. :: Connection
  2. -> [ByteString]
  3. -> [ByteString]
  4. -> STM Message -> IO r
  5. -> IO r
#

Creates a subscription and automatically unsubscribes when callback returns, this function keeps flow control in the callback, so it is useful for short-lived subscriptions, when the callback knows when to exit. The function is quite simple and does not make any attempts to handle connection loss.

Note that this function does not support changing subscriptions while it is running, so it is only useful for short-lived Pub/Sub connections.

An example of usage, that is hard to implement with pubSubForever is to subscribe to a channel:

withPubSub conn ["mychannel"] [] $ \waitMsg -> do
   d <- registerDelay 1000000 -- 1 second (requires -threaded runtime)
   atomically $ asum [ readTVar >>= guard >> return Nothing
                     , Just $ waitMsg
                     ]

In case if connection is lost, user callback will receive BlockedIndefinitelyOnSTM exception.

valuemultiExec :: RedisTx (Queued a) -> Redis (TxResult a)
#

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)
 

Parse a ConnectInfo from a URL according to the Rules in Redis client

Standalone Redis:

redis :// [[username :] password@] host [:port][/database]
Example1 expression
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 = ""})
Example1 expression
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]
Example1 expression
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 = ""})
Example1 expression
parseConnectInfo "redis://username:password@host:42/db"Left "Invalid port: db"

The scheme is validated, to prevent mixing up configurations:

Example1 expression
parseConnectInfo "postgres://"Left "Wrong scheme postgres:"

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

Example1 expression
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 = ""})
newtypenewtype HashSlot
#
Instances7Enum, Eq, Integral, Num, Ord, Real, …
  • Enum HashSlotDefined in hedis-0.16.4 · Database.Redis.Cluster.HashSlot
  • Eq HashSlotDefined in hedis-0.16.4 · Database.Redis.Cluster.HashSlot
  • Integral HashSlotDefined in hedis-0.16.4 · Database.Redis.Cluster.HashSlot
  • Num HashSlotDefined in hedis-0.16.4 · Database.Redis.Cluster.HashSlot
  • Ord HashSlotDefined in hedis-0.16.4 · Database.Redis.Cluster.HashSlot
  • Real HashSlotDefined in hedis-0.16.4 · Database.Redis.Cluster.HashSlot
  • Show HashSlotDefined in hedis-0.16.4 · Database.Redis.Cluster.HashSlot
datadata ConnectInfo
#

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

Instances1Show
classclass MonadRedis m => RedisCtx (m :: Type -> Type) (f :: Type -> Type) | m -> f where
#

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

Instances2RedisCtx
newtypenewtype Redis a
#

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.

Instances11Monad, Functor, MonadFail, Applicative, MonadIO, MonadCatch, …
typetype SendHook = (ByteString -> IO ()) -> ByteString -> IO ()
#

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.

datadata ARInfoResponse
#
Instances3Eq, Show, RedisResult
datadata ClusterInfoResponse
#

Constructors

Instances3Eq, Show, RedisResult
datadata ClusterMigrationTask
#
Instances3Eq, Show, RedisResult
Instances2Eq, Show
Instances3Eq, Show, RedisResult
datadata Condition
#

Constructors

  • Nx

    Only set the key if it does not already exist.

  • Xx

    Only set the key if it already exists.

Instances3Eq, Show, RedisArg
  • Eq ConditionDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • Show ConditionDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • RedisArg ConditionDefined in hedis-0.16.4 · Database.Redis.ManualCommands
newtypenewtype Cursor
#
Instances4Eq, Show, RedisArg, RedisResult
  • Eq CursorDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • Show CursorDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • RedisArg CursorDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • RedisResult CursorDefined in hedis-0.16.4 · Database.Redis.ManualCommands
datadata DebugMode
#
Instances3Eq, Show, RedisArg
  • Eq DebugModeDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • Show DebugModeDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • RedisArg DebugModeDefined in hedis-0.16.4 · Database.Redis.ManualCommands
datadata GeoAddOpts
#

Adds one or more members to a geospatial index (https://redis.io/commands/geoadd). The Redis command GEOADD is split up into geoadd and geoAddOpts. Since Redis 3.2.0

Constructors

Instances2Eq, Show
  • Eq GeoAddOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • Show GeoAddOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands
datadata HotkeysGetResponse
#
Instances3Eq, Show, RedisResult
datadata HotkeysStartOpts
#

Constructors

Instances2Eq, Show
datadata ReplyMode
#
Instances3Eq, Show, RedisArg
  • Eq ReplyModeDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • Show ReplyModeDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • RedisArg ReplyModeDefined in hedis-0.16.4 · Database.Redis.ManualCommands
datadata SetOpts
#

Constructors

Instances2Eq, Show
  • Eq SetOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • Show SetOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands
datadata SizeCondition
#

Constructors

  • CGT

    Only update existing elements if the new score is greater than the current score. This flag doesn't prevent adding new elements.

  • CLT

    Only update existing elements if the new score is less than the current score. This flag doesn't prevent adding new elements.

Instances3Eq, Show, RedisArg
datadata Slowlog
#

A single entry from the slowlog.

Constructors

Instances3Eq, Show, RedisResult
  • Eq SlowlogDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • Show SlowlogDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • RedisResult SlowlogDefined in hedis-0.16.4 · Database.Redis.ManualCommands
datadata TrimStrategy
#

Trimming strategy.

Constructors

  • TrimMaxlen Integer

    Evicts entries as long as the stream's length exceeds the specified threshold, where threshold is a positive integer.

  • TrimMinId ByteString

    Evicts entries with IDs lower than threshold, where threshold is a stream ID.

    Since Redis 6.2: will fail if used on ealier versions.

datadata TrimType
#

Type of the trimming.

Constructors

  • TrimExact

    Exact trimming

  • TrimApprox (Maybe Integer)

    Approximate trimming. Is faster, but may leave slightly more elements in the stream if they can't be immediately deleted.

    Additional parameter Specifies the maximal count of entries that will be evicted. When LIMIT and count aren't specified, the default value of 100 * the number of entries in a macro node will be implicitly used as the count, Just 0 removes the limit entirely.

datadata XAutoclaimResult resultFormat
#

Result of the xautoclaim family of calls

Constructors

Instances3Eq, Show, RedisResult
datadata XGroupCreateOpts
#

Additional parameters of the XGroupCreate

Constructors

  • XGroupCreateOpts
    • xGroupCreateMkStream :: Bool

      If a stream does not exist, create it automatically with length of 0

    • xGroupCreateEntriesRead :: Maybe ByteString

      Enable consumer group lag tracking, specify an arbitrary ID. An arbitrary ID is any ID that isn't the ID of the stream's first entry, last entry, or zero ("0-0") ID. Use it to find out how many entries are between the arbitrary ID (excluding it) and the stream's last entry.

      Since Redis 7.0, fails if set on the ealier versions.

Instances2Eq, Show

Data structure that is returned as a result of xinfoConsumers

Constructors

Instances3Eq, Show, RedisResult
datadata XInfoGroupsResponse
#

Result of the xinfoGroups call.

Constructors

Instances3Eq, Show, RedisResult
datadata XInfoStreamResponse
#

Constructors

Instances3Eq, Show, RedisResult
datadata XPendingDetailRecord
#

Details about message returned by the xpendingDetails

Instances3Eq, Show, RedisResult
Instances3Eq, Show, RedisResult
datadata XRefPolicy
#

Constructors

  • XRefPolicyKeepRef

    Deletes the specified entries from the stream, but preserves existing references to these entries in all consumer groups

  • XRefPolicyDelRef

    Deletes the specified entries from the stream and also removes all references to these entries from all consumer groups' pending entry lists, effectively cleaning up all traces of the messages. If an entry ID is not in the stream, but there are dangling references, XDELEX with DELREF would still remove all those references.

  • XRefPolicyAcked

    Deletes the specified entries from the stream only if they have been acknowledged by all consumer groups.

Instances3Eq, Show, RedisArg
datadata ZAggregateOpts
#

Constructors

  • ZAggregateOpts
    • zAggregateWeights :: [Double]

      WEIGHTS option, it is possible to specify a multiplication factor for each input sorted set. Each element's score is multiplied by its corresponding weight before aggregation. When WEIGHTS is not given, the multiplication factors default to 1.

    • zAggregateAggregate :: Aggregate

      AGGREGATE option, it is possible to specify how the results of the union are aggregated

Instances2Eq, Show
datadata ZaddOpts
#

Add one or more members to a sorted set, or update its score if it already exists (http://redis.io/commands/zadd). The Redis command ZADD is split up into zadd, zaddOpts. Since Redis 1.2.0

Constructors

Instances2Eq, Show
  • Eq ZaddOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands
  • Show ZaddOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands
datadata BFInfo
#

Constructors

Instances3Eq, Show, RedisResult
  • Eq BFInfoDefined in hedis-0.16.4 · Database.Redis.ManualCommands.BF
  • Show BFInfoDefined in hedis-0.16.4 · Database.Redis.ManualCommands.BF
  • RedisResult BFInfoDefined in hedis-0.16.4 · Database.Redis.ManualCommands.BF
datadata BFInsertOpts
#

Constructors

Instances2Eq, Show
  • Eq BFInsertOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands.BF
  • Show BFInsertOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands.BF
datadata CFInfo
#

Constructors

Instances3Eq, Show, RedisResult
  • Eq CFInfoDefined in hedis-0.16.4 · Database.Redis.ManualCommands.CF
  • Show CFInfoDefined in hedis-0.16.4 · Database.Redis.ManualCommands.CF
  • RedisResult CFInfoDefined in hedis-0.16.4 · Database.Redis.ManualCommands.CF
datadata FTAggregateOpts
#
Instances2Eq, Show
datadata FTCreateField
#
Instances2Eq, Show
datadata FTCreateOpts
#
Instances2Eq, Show
  • Eq FTCreateOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands.FT
  • Show FTCreateOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands.FT
datadata FTHybridCombine
#
Instances2Eq, Show
datadata FTHybridOpts
#
Instances2Eq, Show
  • Eq FTHybridOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands.FT
  • Show FTHybridOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands.FT
datadata FTHybridVectorQuery
#
Instances2Eq, Show
datadata FTOn
#
Instances3Eq, Show, RedisArg
  • Eq FTOnDefined in hedis-0.16.4 · Database.Redis.ManualCommands.FT
  • Show FTOnDefined in hedis-0.16.4 · Database.Redis.ManualCommands.FT
  • RedisArg FTOnDefined in hedis-0.16.4 · Database.Redis.ManualCommands.FT
datadata FTSearchOpts
#
Instances2Eq, Show
  • Eq FTSearchOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands.FT
  • Show FTSearchOptsDefined in hedis-0.16.4 · Database.Redis.ManualCommands.FT
datadata TDigestInfo
#

Constructors

Instances3Eq, Show, RedisResult
datadata TopkInfo
#

Constructors

Instances3Eq, Show, RedisResult
  • Eq TopkInfoDefined in hedis-0.16.4 · Database.Redis.ManualCommands.Topk
  • Show TopkInfoDefined in hedis-0.16.4 · Database.Redis.ManualCommands.Topk
  • RedisResult TopkInfoDefined in hedis-0.16.4 · Database.Redis.ManualCommands.Topk
datadata WaitAofResult
#

Constructors

Instances3Eq, Show, RedisResult
datadata Reply
#

Low-level representation of replies from the Redis server.

Instances7Eq, Show, Generic, NFData, RedisResult, RedisCtx, …
typetype MessageCallback = ByteString -> IO ()
#

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.

datadata PubSubController
#

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.

typetype UnregisterCallbacksAction = IO ()
#

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 -}
datadata Queued a
#

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.

Instances4Monad, Functor, Applicative, RedisCtx
newtypenewtype RedisTx a
#

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.

Instances6Monad, Functor, Applicative, MonadIO, MonadRedis, RedisCtx
datadata TxResult a
#

Result of a multiExec transaction.

Constructors

Instances5Eq, Show, Generic, NFData, Rep
classclass RedisArg a where
#

Methods

Instances35RedisArg, …
classclass RedisResult a where
#

Methods

Instances58RedisResult, …
datadata Status
#
Instances6Eq, Show, Generic, NFData, RedisResult, Rep