{-# LANGUAGE OverloadedStrings, FlexibleContexts, OverloadedLists #-}

module Database.Redis.Commands (

-- * Connection

-- ** Auth
-- $auth
auth,
authOpts,
AuthOpts(..),
defaultAuthOpts,
-- ** Other commands
echo,
ping,
quit,
select,

-- * Generic keys
copy,
copyOpts,
CopyOpts(..),
defaultCopyOpts,
del,
dump,
exists,
expire,
expireOpts,
ExpireOpts(..),
expireat,
expireatOpts,
keys,
MigrateOpts(..),
defaultMigrateOpts,
migrate,
migrateMultiple,
move,
objectRefcount,
objectEncoding,
objectIdletime,
persist,
expiretime,
pexpire,
pexpiretime,
pexpireat,
pexpireatOpts,
pttl,
randomkey,
rename,
renamenx,
restore,
restoreReplace,
Cursor,
cursor0,
ScanOpts(..),
defaultScanOpts,
scan,
scanOpts,
SortOpts(..),
defaultSortOpts,
SortOrder(..),
sort,
sortStore,
ttl,
RedisType(..),
getType,


-- * Hashes
hdel,
HashFieldExpirationStatus(..),
HashFieldExpirationInfo(..),
hexists,
hexpire,
hexpireOpts,
hexpireat,
hexpireatOpts,
hexpiretime,
hget,
hgetdel,
hgetex,
HGetExOpts(..),
defaultHGetExOpts,
hgetexOpts,
hgetall,
hincrby,
hincrbyfloat,
hkeys,
hlen,
hmget,
hmset,
hrandfield,
hrandfieldCount,
hrandfieldCountWithValues,
hscan,
hscanOpts,
hpexpire,
hpexpireOpts,
hpexpireat,
hpexpireatOpts,
hpexpiretime,
hpttl,
hset,
hsetex,
HSetExCondition(..),
HSetExOpts(..),
defaultHSetExOpts,
hsetexOpts,
hsetnx,
hstrlen,
httl,
hvals,

-- * HyperLogLogs
pfadd,
pfcount,
pfmerge,

-- * Lists
blpop,
blpopFloat,
blmpop,
blmpopCount,
blmove,
ListDirection(..),
brpop,
brpopFloat,
brpoplpush,
lindex,
linsertBefore,
linsertAfter,
llen,
lmpop,
lmpopCount,
lpos,
LPosOpts(..),
defaultLPosOpts,
lposOpts,
lposCount,
lposCountOpts,
lpop,
lpopCount,
lmove,
lpush,
lpushx,
lrange,
lrem,
lset,
ltrim,
rpop,
rpopCount,
rpoplpush,
rpush,
rpushx,

-- * Scripting
eval,
evalsha,
fcall,
fcallReadonly,
DebugMode,
functionHelp,
functionList,
FunctionListOpts(..),
defaultFunctionListOpts,
functionListOpts,
module Function,
scriptDebug,
scriptExists,
scriptFlush,
scriptKill,
scriptLoad,

-- * Server
bgrewriteaof,
bgsave,
bgsaveSchedule,
clientGetname,
clientId,
clientList,
clientPause,
ReplyMode,
clientReply,
clientUnpause,
clientSetname,
clientNoTouch,
clientSetinfo,

commandCount,
commandInfo,
commandList,
CommandListFilter(..),
commandListOpts,
HotkeysMetric(..),
HotkeysStartOpts(..),
defaultHotkeysStartOpts,
HotkeysSlotRange(..),
HotkeysGetResponse(..),
hotkeysGet,
hotkeysStart,
hotkeysStartOpts,
hotkeysStop,
hotkeysReset,
configGet,
configResetstat,
configRewrite,
configSet,
dbsize,
debugObject,
flushall,
flushallOpts,
FlushOpts(..),
flushdb,
flushdbOpts,
info, -- |Get information and statistics about the server (<http://redis.io/commands/info>). The Redis command @INFO@ is split up into 'info', 'infoSection'. Since Redis 1.0.0
infoSection, -- |Get information and statistics about the server (<http://redis.io/commands/info>). The Redis command @INFO@ is split up into 'info', 'infoSection'. Since Redis 1.0.0
lastsave, -- |Get the UNIX time stamp of the last successful save to disk (<http://redis.io/commands/lastsave>). Since Redis 1.0.0
save,
slaveof,
Slowlog(..),
slowlogGet, -- |Manages the Redis slow queries log (<http://redis.io/commands/slowlog>). The Redis command @SLOWLOG@ is split up into 'slowlogGet', 'slowlogLen', 'slowlogReset'. Since Redis 2.2.12
slowlogLen, -- |Manages the Redis slow queries log (<http://redis.io/commands/slowlog>). The Redis command @SLOWLOG@ is split up into 'slowlogGet', 'slowlogLen', 'slowlogReset'. Since Redis 2.2.12
slowlogReset, -- |Manages the Redis slow queries log (<http://redis.io/commands/slowlog>). The Redis command @SLOWLOG@ is split up into 'slowlogGet', 'slowlogLen', 'slowlogReset'. Since Redis 2.2.12
time,

-- * Sets
sadd,
scard,
sdiff,
sdiffstore,
sinter,
sintercard,
SintercardOpts(..),
defaultSintercardOpts,
sintercardOpts,
sinterstore,
sismember,
smembers,
smismember,
smove,
spop,
spopN,
srandmember,
srandmemberN,
srem,
sscan,
sscanOpts,
sunion,
sunionstore,

-- * Sorted Sets
bzpopmax,
bzpopmin,
ZaddOpts(..),
defaultZaddOpts,
zadd,
zaddOpts,
zcard,
zcount,
zdiff,
zdiffWithscores,
zdiffstore,
SizeCondition(..),
zincrby,
Aggregate(..),
ZPopMinMax(..),
ZPopResponse(..),
zmpop,
zmpopCount,
bzmpop,
bzmpopCount,
ZAggregateOpts(..),
defaultZAggregateOpts,
zinter,
zinterWithscores,
zinterOpts,
zinterWithscoresOpts,
zinterstore,
zinterstoreWeights,
zlexcount,
zmscore,
zpopmin,
zpopmax,
zrandmember,
zrandmemberN,
zrandmemberWithscores,
zrange,
zrangeWithscores,
ZRangeStoreRange(..),
ZRangeStoreOpts(..),
defaultZRangeStoreOpts,
zrangestore,
zrangestoreOpts,
RangeLex(..),
zrangebylex,
zrangebylexLimit,
zrangebyscore, -- |Return a range of members in a sorted set, by score (<http://redis.io/commands/zrangebyscore>). The Redis command @ZRANGEBYSCORE@ is split up into 'zrangebyscore', 'zrangebyscoreWithscores', 'zrangebyscoreLimit', 'zrangebyscoreWithscoresLimit'. Since Redis 1.0.5
zrangebyscoreWithscores, -- |Return a range of members in a sorted set, by score (<http://redis.io/commands/zrangebyscore>). The Redis command @ZRANGEBYSCORE@ is split up into 'zrangebyscore', 'zrangebyscoreWithscores', 'zrangebyscoreLimit', 'zrangebyscoreWithscoresLimit'. Since Redis 1.0.5
zrangebyscoreLimit, -- |Return a range of members in a sorted set, by score (<http://redis.io/commands/zrangebyscore>). The Redis command @ZRANGEBYSCORE@ is split up into 'zrangebyscore', 'zrangebyscoreWithscores', 'zrangebyscoreLimit', 'zrangebyscoreWithscoresLimit'. Since Redis 1.0.5
zrangebyscoreWithscoresLimit, -- |Return a range of members in a sorted set, by score (<http://redis.io/commands/zrangebyscore>). The Redis command @ZRANGEBYSCORE@ is split up into 'zrangebyscore', 'zrangebyscoreWithscores', 'zrangebyscoreLimit', 'zrangebyscoreWithscoresLimit'. Since Redis 1.0.5
zrank,
zrankWithScore,
zrem,
zremrangebylex,
zremrangebyrank,
zremrangebyscore,
zrevrange, -- |Return a range of members in a sorted set, by index, with scores ordered from high to low (<http://redis.io/commands/zrevrange>). The Redis command @ZREVRANGE@ is split up into 'zrevrange', 'zrevrangeWithscores'. Since Redis 1.2.0
zrevrangeWithscores, -- |Return a range of members in a sorted set, by index, with scores ordered from high to low (<http://redis.io/commands/zrevrange>). The Redis command @ZREVRANGE@ is split up into 'zrevrange', 'zrevrangeWithscores'. Since Redis 1.2.0
zrevrangebyscore, -- |Return a range of members in a sorted set, by score, with scores ordered from high to low (<http://redis.io/commands/zrevrangebyscore>). The Redis command @ZREVRANGEBYSCORE@ is split up into 'zrevrangebyscore', 'zrevrangebyscoreWithscores', 'zrevrangebyscoreLimit', 'zrevrangebyscoreWithscoresLimit'. Since Redis 2.2.0
zrevrangebyscoreWithscores, -- |Return a range of members in a sorted set, by score, with scores ordered from high to low (<http://redis.io/commands/zrevrangebyscore>). The Redis command @ZREVRANGEBYSCORE@ is split up into 'zrevrangebyscore', 'zrevrangebyscoreWithscores', 'zrevrangebyscoreLimit', 'zrevrangebyscoreWithscoresLimit'. Since Redis 2.2.0
zrevrangebyscoreLimit, -- |Return a range of members in a sorted set, by score, with scores ordered from high to low (<http://redis.io/commands/zrevrangebyscore>). The Redis command @ZREVRANGEBYSCORE@ is split up into 'zrevrangebyscore', 'zrevrangebyscoreWithscores', 'zrevrangebyscoreLimit', 'zrevrangebyscoreWithscoresLimit'. Since Redis 2.2.0
zrevrangebyscoreWithscoresLimit, -- |Return a range of members in a sorted set, by score, with scores ordered from high to low (<http://redis.io/commands/zrevrangebyscore>). The Redis command @ZREVRANGEBYSCORE@ is split up into 'zrevrangebyscore', 'zrevrangebyscoreWithscores', 'zrevrangebyscoreLimit', 'zrevrangebyscoreWithscoresLimit'. Since Redis 2.2.0
zrevrank,
zrevrankWithScore,
zscan, -- |Incrementally iterate sorted sets elements and associated scores (<http://redis.io/commands/zscan>). The Redis command @ZSCAN@ is split up into 'zscan', 'zscanOpts'. Since Redis 2.8.0
zscanOpts, -- |Incrementally iterate sorted sets elements and associated scores (<http://redis.io/commands/zscan>). The Redis command @ZSCAN@ is split up into 'zscan', 'zscanOpts'. Since Redis 2.8.0
zscore,
zunion,
zunionWithscores,
zunionOpts,
zunionWithscoresOpts,
zunionstore, -- |Add multiple sorted sets and store the resulting sorted set in a new key (<http://redis.io/commands/zunionstore>). The Redis command @ZUNIONSTORE@ is split up into 'zunionstore', 'zunionstoreWeights'. Since Redis 2.0.0
zunionstoreWeights, -- |Add multiple sorted sets and store the resulting sorted set in a new key (<http://redis.io/commands/zunionstore>). The Redis command @ZUNIONSTORE@ is split up into 'zunionstore', 'zunionstoreWeights'. Since Redis 2.0.0

-- * Vector Sets
VAddQuantization(..),
VAddOpts(..),
defaultVAddOpts,
VQuantization(..),
VEmbRawResponse(..),
VInfoResponse(..),
VLinksResponse(..),
VLinksWithScoresResponse(..),
VSimQuery(..),
VSimOpts(..),
defaultVSimOpts,
VSimWithAttribsResult(..),
VSimWithAttribsResponse(..),
vadd,
vaddOpts,
vcard,
vdim,
vemb,
vembRaw,
vgetattr,
vinfo,
vismember,
vlinks,
vlinksWithScores,
vrandmember,
vrandmemberCount,
vrange,
vrangeCount,
vrem,
vsetattr,
vsim,
vsimOpts,
vsimWithScores,
vsimWithScoresOpts,
vsimWithScoresWithAttribs,
vsimWithScoresWithAttribsOpts,

-- * Arrays
ARGrepPredicate(..),
ARGrepCombine(..),
ARGrepOpts(..),
defaultARGrepOpts,
ARLastItemsOpts(..),
defaultARLastItemsOpts,
ARScanOpts(..),
defaultARScanOpts,
ARIndexValuePairsResponse(..),
ARInfoResponse(..),
AROpValue(..),
AROpCount(..),
arcount,
ardel,
argetrange,
argrep,
argrepOpts,
argrepWithValues,
argrepWithValuesOpts,
arinfo,
arinfoFull,
arinsert,
arlastitems,
arlastitemsOpts,
arlen,
armget,
arnext,
aropValue,
aropCount,
arring,
arscan,
arscanOpts,
arseek,
arset,

-- * Strings
append,
bitcount, -- |Count set bits in a string (<http://redis.io/commands/bitcount>). The Redis command @BITCOUNT@ is split up into 'bitcount', 'bitcountRange'. Since Redis 2.6.0
bitcountRange, -- |Count set bits in a string (<http://redis.io/commands/bitcount>). The Redis command @BITCOUNT@ is split up into 'bitcount', 'bitcountRange'. Since Redis 2.6.0
bitopAnd, -- |Perform bitwise operations between strings (<http://redis.io/commands/bitop>). The Redis command @BITOP@ is split up into 'bitopAnd', 'bitopOr', 'bitopXor', 'bitopNot'. Since Redis 2.6.0
bitopOr, -- |Perform bitwise operations between strings (<http://redis.io/commands/bitop>). The Redis command @BITOP@ is split up into 'bitopAnd', 'bitopOr', 'bitopXor', 'bitopNot'. Since Redis 2.6.0
bitopXor, -- |Perform bitwise operations between strings (<http://redis.io/commands/bitop>). The Redis command @BITOP@ is split up into 'bitopAnd', 'bitopOr', 'bitopXor', 'bitopNot'. Since Redis 2.6.0
bitopNot, -- |Perform bitwise operations between strings (<http://redis.io/commands/bitop>). The Redis command @BITOP@ is split up into 'bitopAnd', 'bitopOr', 'bitopXor', 'bitopNot'. Since Redis 2.6.0
bitpos,
bitposOpts,
BitposOpts(..),
BitposType(..),
decr,
decrby,
delex,
DelexCondition(..),
delexWhen,
digest,
get,
getbit,
getdel,
getex,
IncrexExpiration(..),
IncrexOpts(..),
defaultIncrexOpts,
increx,
increxOpts,
increxBy,
increxByFloat,
GetExOpts(..),
defaultGetExOpts,
getexOpts,
getrange,
getset,
incr,
incrby,
incrbyfloat,
mget,
mset,
msetex,
msetexOpts,
msetnx,
psetex,
Condition(..),
SetOpts(..),
defaultSetOpts,
set, -- |Set the string value of a key (<http://redis.io/commands/set>). The Redis command @SET@ is split up into 'set', 'setOpts', 'setGet', 'setGetOpts'. Since Redis 1.0.0
setOpts, -- |Set the string value of a key (<http://redis.io/commands/set>). The Redis command @SET@ is split up into 'set', 'setOpts', 'setGet', 'setGetOpts'. Since Redis 1.0.0
setGet, -- |Set the string value of a key (<http://redis.io/commands/set>). The Redis command @SET@ is split up into 'set', 'setOpts', 'setGet', 'setGetOpts'. Since Redis 1.0.0
setGetOpts, -- |Set the string value of a key (<http://redis.io/commands/set>). The Redis command @SET@ is split up into 'set', 'setOpts', 'setGet', 'setGetOpts'. Since Redis 1.0.0
setbit,
setex,
setnx,
setrange,
strlen,
substr,


-- * Streams
XReadOpts(..),
defaultXreadOpts,
XReadResponse(..),
StreamsRecord(..),
xadd,
xaddOpts,
XAddOpts(..),
defaultXAddOpts,
TrimStrategy(..),
TrimType(..),
trimOpts,
xread,
xreadOpts,
xreadGroup, -- |Read values from a stream as part of a consumer group (https://redis.io/commands/xreadgroup). The redis command @XREADGROUP@ is split up into 'xreadGroup' and 'xreadGroupOpts'. Since Redis 5.0.0
XReadGroupOpts(..),
defaultXReadGroupOpts,
xreadGroupOpts, -- |Read values from a stream as part of a consumer group (https://redis.io/commands/xreadgroup). The redis command @XREADGROUP@ is split up into 'xreadGroup' and 'xreadGroupOpts'. Since Redis 5.0.0
xack, -- |Acknowledge receipt of a message as part of a consumer group. Since Redis 5.0.0
xackdel,
xackdelOpts,
XRefPolicy(..),
XEntryDeletionOpts(..),
defaultXEntryDeletionOpts,
XEntryDeletionResult(..),
XCfgSetOpts(..),
defaultXCfgSetOpts,
xcfgset,
XNackMode(..),
XNackOpts(..),
defaultXNackOpts,
xidmprecord,
xnack,
xnackOpts,

-- $xgroupCreate
xgroupCreate,
xgroupCreateOpts,
XGroupCreateOpts(..),
defaultXGroupCreateOpts,

xgroupCreateConsumer,

-- $xgroupSetId
xgroupSetId,
xgroupSetIdOpts,
XGroupSetIdOpts(..),
defaultXGroupSetIdOpts,

xgroupDestroy,

xgroupDelConsumer,

xrange, -- |Read values from a stream within a range (https://redis.io/commands/xrange). Since Redis 5.0.0
xrevRange, -- |Read values from a stream within a range in reverse order (https://redis.io/commands/xrevrange). Since Redis 5.0.0
xlen, -- |Get the number of entries in a stream (https://redis.io/commands/xlen). Since Redis 5.0.0

-- $xpending
xpendingSummary,
XPendingSummaryResponse(..),
XPendingDetailOpts(..),
defaultXPendingDetailOpts,
XPendingDetailRecord(..),
xpendingDetail,

XClaimOpts(..),
defaultXClaimOpts,
xclaim, -- |Change ownership of some messages to the given consumer, returning the updated messages. The Redis @XCLAIM@ command is split into 'xclaim' and 'xclaimJustIds'. Since Redis 5.0.0
xclaimJustIds, -- |Change ownership of some messages to the given consumer, returning only the changed message IDs. The Redis @XCLAIM@ command is split into 'xclaim' and 'xclaimJustIds'. Since Redis 5.0.0
-- $autoclaim
xautoclaim,
xautoclaimOpts,
XAutoclaimOpts(..),
XAutoclaimStreamsResult,
XAutoclaimResult(..),
xautoclaimJustIds,
xautoclaimJustIdsOpts,
XAutoclaimJustIdsResult,
XInfoConsumersResponse(..),
xinfoConsumers,
XInfoGroupsResponse(..),
xinfoGroups,
XInfoStreamResponse(..),
xinfoStream,
xdel,
xdelex,
xdelexOpts,
xtrim,

-- * Geo commands
GeoUnit(..),
GeoOrder(..),
GeoCoordinates(..),
GeoLocation(..),
GeoSearchFrom(..),
GeoSearchBy(..),
GeoSearchOpts(..),
defaultGeoSearchOpts,
GeoSearchStoreOpts(..),
defaultGeoSearchStoreOpts,
GeoAddOpts(..),
defaultGeoAddOpts,
geoadd,
geoaddOpts,
geodist,
geopos,
geoSearch,
geoSearchStore,

-- * Redis stack
-- ** Wait
module Wait,

-- ** Bloom Filters
module BF,

-- ** Cuckoo Filters
module CF,

-- ** Count-Min Sketches
module Cms,

-- ** Top-K
module Topk,

-- ** T-Digest
module Tdigest,

-- ** Time Series
module Ts,

-- ** Redis Indexes
module FT,

-- ** JSON
module JSON,

-- * Cluster commands
inf,
ClusterInfoResponse (..),
ClusterInfoResponseState (..),
clusterInfo,
clusterMyshardid,
ClusterNodesResponse(..),
ClusterNodesResponseEntry(..),
ClusterNodesResponseSlotSpec(..),
clusterNodes,
ClusterSlotsResponse(..),
ClusterSlotsResponseEntry(..),
ClusterSlotsNode(..),
clusterSlots,
ClusterSlotStatsMetric(..),
ClusterSlotStatsOrderByOpts(..),
defaultClusterSlotStatsOrderByOpts,
ClusterSlotStatsQuery(..),
ClusterSlotStatsResponse(..),
ClusterSlotStatsResponseEntry(..),
clusterSlotStats,
clusterSlotStatsSlotsRange,
clusterSlotStatsOrderBy,
clusterSlotStatsOrderByOpts,
ClusterMigrationSlotRange(..),
ClusterMigrationTask(..),
ClusterMigrationStatusResponse(..),
clusterMigrationImport,
clusterMigrationCancelId,
clusterMigrationCancelAll,
clusterMigrationStatus,
clusterMigrationStatusAll,
clusterMigrationStatusId,
clusterSetSlotNode,
clusterSetSlotStable,
clusterSetSlotImporting,
clusterSetSlotMigrating,
clusterGetKeysInSlot,
command
-- * Unimplemented Commands
-- |These commands are not implemented, as of now. Library
--  users can implement these or other commands from
--  experimental Redis versions by using the 'sendRequest'
--  function.
--
-- * COMMAND (<http://redis.io/commands/command>)
--
--
-- * COMMAND GETKEYS (<http://redis.io/commands/command-getkeys>)
--
--
-- * ROLE (<http://redis.io/commands/role>)
--
--
-- * CLIENT KILL (<http://redis.io/commands/client-kill>)
--
--
-- * ZREVRANGEBYLEX (<http://redis.io/commands/zrevrangebylex>)
--
--
-- * ZRANGEBYSCORE (<http://redis.io/commands/zrangebyscore>)
--
--
-- * ZREVRANGEBYSCORE (<http://redis.io/commands/zrevrangebyscore>)
--
--
-- * MONITOR (<http://redis.io/commands/monitor>)
--
--
-- * SYNC (<http://redis.io/commands/sync>)
--
--
-- * SHUTDOWN (<http://redis.io/commands/shutdown>)
--
--
-- * DEBUG SEGFAULT (<http://redis.io/commands/debug-segfault>)
--
) where

import Prelude hiding (min,max)
import Data.Int
import Data.ByteString (ByteString)
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NE
import Database.Redis.ManualCommands.BF as BF
import Database.Redis.ManualCommands.CF as CF
import Database.Redis.ManualCommands.Cms as Cms
import Database.Redis.ManualCommands.FT as FT
import Database.Redis.ManualCommands.Function as Function
import Database.Redis.ManualCommands.JSON as JSON
import Database.Redis.ManualCommands.Tdigest as Tdigest
import Database.Redis.ManualCommands.Ts as Ts
import Database.Redis.ManualCommands.Topk as Topk
import Database.Redis.ManualCommands.Wait as Wait
import Database.Redis.ManualCommands
import Database.Redis.Types
import Database.Redis.Core(sendRequest, RedisCtx)

-- | /O(1)/
-- Get the time to live for a key (<http://redis.io/commands/ttl>).
-- Since Redis 1.0.0
--
-- This command returns:
--   * -2 if the key does not exist
--   * -1 if the key exists but has no associated value
--
ttl
    :: (RedisCtx m f)
    => ByteString -- ^ Key to check.
    -> m (f Integer)
ttl :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
ttl ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"TTL", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key]

-- | /O(1)/
-- Sets the value of a key, only if the key does not exist (<http://redis.io/commands/setnx>).
--
-- Returns a result if a value was set.
--
-- Since Redis 1.0.0
setnx
    :: (RedisCtx m f)
    => ByteString -- ^ Key to set.
    -> ByteString -- ^ Value to set.
    -> m (f Bool)
setnx :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Bool)
setnx ByteString
key ByteString
value = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SETNX", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key, ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
value]

-- | /O(1)/
-- Get the time to live for a key in milliseconds (<http://redis.io/commands/pttl>).
-- Since Redis 2.6.0
--
-- This command returns @-2@ if the key does not exist.
-- This command returns @-1@ if the key exists but has no associated value
pttl
    :: (RedisCtx m f)
    => ByteString -- ^ Key.
    -> m (f Integer)
pttl :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
pttl ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"PTTL", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key]

-- | /O(1)/
-- Get total number of Redis commands (<http://redis.io/commands/command-count>).
-- Since Redis 2.8.13
commandCount
    :: (RedisCtx m f)
    => m (f Integer)
commandCount :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Integer)
commandCount  = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"COMMAND",Item [ByteString]
ByteString
"COUNT"]

-- | Set the current connection name (<http://redis.io/commands/client-setname>).
-- Since Redis 2.6.9
clientSetname
    :: (RedisCtx m f)
    => ByteString -- ^ Connection Name.
    -> m (f Status)
clientSetname :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Status)
clientSetname ByteString
connectionName = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"CLIENT",Item [ByteString]
ByteString
"SETNAME",ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
connectionName]

-- | Determine the index of a member in a sorted set (<http://redis.io/commands/zrank>).
--
-- Since Redis 2.0.0
zrank
    :: (RedisCtx m f)
    => ByteString -- ^ Key.of the set.
    -> ByteString -- ^ Member
    -> m (f (Maybe Integer))
zrank :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe Integer))
zrank ByteString
key ByteString
member = [ByteString] -> m (f (Maybe Integer))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZRANK", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key, ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
member]

-- |
-- Since  Redis 7.2.0: fails on earlier versions
zrankWithScore
    :: (RedisCtx m f)
    => ByteString -- ^ Key of the set.
    -> ByteString -- ^ Member.
    -> m (f (Maybe (Integer,Double)))
zrankWithScore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe (Integer, Double)))
zrankWithScore ByteString
key ByteString
member = [ByteString] -> m (f (Maybe (Integer, Double)))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZRANK", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key, ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
member, Item [ByteString]
ByteString
"WITHSCORE"]

-- | /O(log(N)+M)/ with @N@ number of elements in the set, @M@ number of elements to be removed.
--
-- Remove all members in a sorted set within the given scores (<http://redis.io/commands/zremrangebyscore>).
--
-- Returns a number of elements that were removed.
--
-- Since Redis 1.2.0
zremrangebyscore
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Double -- ^ min
    -> Double -- ^ max
    -> m (f Integer)
zremrangebyscore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> Double -> m (f Integer)
zremrangebyscore ByteString
key Double
min Double
max =
  [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZREMRANGEBYSCORE",ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key,Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
min,Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
max]

-- | /O(N)/ where @N@ is size of the hash.
-- Get all the fields in a hash (<http://redis.io/commands/hkeys>).
-- Since Redis 2.0.0
hkeys
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f [ByteString])
hkeys :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f [ByteString])
hkeys ByteString
key = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"HKEYS",ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key]

-- |Make the server a slave of another instance, or promote it as master (<http://redis.io/commands/slaveof>).
-- Deprecated in Redis, can be replaced by replicaif since redis 5.0
-- Since Redis 1.0.0
slaveof
    :: (RedisCtx m f)
    => ByteString -- ^ host
    -> ByteString -- ^ port
    -> m (f Status)
slaveof :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Status)
slaveof ByteString
host ByteString
port = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SLAVEOF",ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
host,ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
port]

-- | /O(1)/ for each element added.
-- Append a value to a list, only if the list exists (<http://redis.io/commands/rpushx>).
-- Since Redis 2.2.0
rpushx
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> NonEmpty ByteString -- ^ value
    -> m (f Integer)
rpushx :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
rpushx ByteString
key (ByteString
value:|[ByteString]
values) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"RPUSHX"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
valueByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
values)

-- |Get debugging information about a key (<http://redis.io/commands/debug-object>). Since Redis 1.0.0
debugObject
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f ByteString)
debugObject :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ByteString)
debugObject ByteString
key = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"DEBUG",Item [ByteString]
ByteString
"OBJECT",ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key]

-- |Asynchronously save the dataset to disk (<http://redis.io/commands/bgsave>).
--
-- Since Redis 1.0.0
bgsave
    :: (RedisCtx m f)
    => m (f Status)
bgsave :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
bgsave  = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"BGSAVE"]

-- |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
bgsaveSchedule
    :: (RedisCtx m f)
    => m (f Status)
bgsaveSchedule :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
bgsaveSchedule = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"BGSAVE", Item [ByteString]
ByteString
"SCHEDULE"]


-- | /O(1)/ Get the number of fields in a hash (<http://redis.io/commands/hlen>).
--
-- Since Redis 2.0.0
hlen
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f Integer)
hlen :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
hlen ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"HLEN", Item [ByteString]
ByteString
key]

-- |Remove the last element in a list, prepend it to another list and return that
-- element f it existed (<http://redis.io/commands/rpoplpush>).
-- Since Redis 1.2.0
rpoplpush
    :: (RedisCtx m f)
    => ByteString -- ^ source
    -> ByteString -- ^ destination
    -> m (f (Maybe ByteString))
rpoplpush :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe ByteString))
rpoplpush ByteString
source ByteString
destination = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"RPOPLPUSH",ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
source,ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
destination]

-- | /O(N)/
-- Remove and get the last element in a list, or block until one is available (<http://redis.io/commands/brpop>).
--
-- Since Redis 2.0.0
brpop
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ key
    -> Integer -- ^ timeout
    -> m (f (Maybe (ByteString,ByteString)))
brpop :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> Integer -> m (f (Maybe (ByteString, ByteString)))
brpop (ByteString
key:|[ByteString]
rest) Integer
timeout = [ByteString] -> m (f (Maybe (ByteString, ByteString)))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ((ByteString
"BRPOP"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
rest)  [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeout])

-- | /O(N)/
-- Remove and get the last element in a list, or block until one is available (<http://redis.io/commands/brpop>).
--
-- Since Redis 2.0.0
brpopFloat
    :: (RedisCtx m f)
    => [ByteString] -- ^ key
    -> Double -- ^ timeout
    -> m (f (Maybe (ByteString,ByteString)))
brpopFloat :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
[ByteString] -> Double -> m (f (Maybe (ByteString, ByteString)))
brpopFloat [ByteString]
key Double
timeout = [ByteString] -> m (f (Maybe (ByteString, ByteString)))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([Item [ByteString]
ByteString
"BRPOP"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (ByteString -> ByteString) -> [ByteString] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode [ByteString]
key [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
timeout])

-- |Remove and return the member with the highest score from one or more sorted sets, or block until one is available (<http://redis.io/commands/bzpopmax>).
--
-- Since Redis 5.0.0
bzpopmax
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ keys
    -> Double -- ^ timeout
    -> m (f (Maybe (ByteString, ByteString, Double)))
bzpopmax :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> Double -> m (f (Maybe (ByteString, ByteString, Double)))
bzpopmax (ByteString
key:|[ByteString]
keys_) Double
timeout = [ByteString] -> m (f (Maybe (ByteString, ByteString, Double)))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe (ByteString, ByteString, Double))))
-> [ByteString] -> m (f (Maybe (ByteString, ByteString, Double)))
forall a b. (a -> b) -> a -> b
$ ByteString
"BZPOPMAX" ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
key ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
keys_ [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
timeout]

-- |Remove and return the member with the lowest score from one or more sorted sets, or block until one is available (<http://redis.io/commands/bzpopmin>).
--
-- Since Redis 5.0.0
bzpopmin
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ keys
    -> Double -- ^ timeout
    -> m (f (Maybe (ByteString, ByteString, Double)))
bzpopmin :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> Double -> m (f (Maybe (ByteString, ByteString, Double)))
bzpopmin (ByteString
key:|[ByteString]
keys_) Double
timeout = [ByteString] -> m (f (Maybe (ByteString, ByteString, Double)))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe (ByteString, ByteString, Double))))
-> [ByteString] -> m (f (Maybe (ByteString, ByteString, Double)))
forall a b. (a -> b) -> a -> b
$ ByteString
"BZPOPMIN" ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
key ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
keys_ [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
timeout]

-- |Asynchronously rewrite the append-only file (<http://redis.io/commands/bgrewriteaof>). Since Redis 1.0.0
bgrewriteaof
    :: (RedisCtx m f)
    => m (f Status)
bgrewriteaof :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
bgrewriteaof  = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"BGREWRITEAOF"]

-- | /O(log(N))/
--
-- Increment the score of a member in a sorted set (<http://redis.io/commands/zincrby>).
--
-- Returns new score of the element.
--
-- Since Redis 1.2.0
zincrby
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ increment
    -> ByteString -- ^ member
    -> m (f Double)
zincrby :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ByteString -> m (f Double)
zincrby ByteString
key Integer
increment ByteString
member = [ByteString] -> m (f Double)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZINCRBY",ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key,Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
increment,ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
member]

-- | Get all the fields and values in a hash (<http://redis.io/commands/hgetall>).
--
-- Since Redis 2.0.0.
hgetall
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f [(ByteString,ByteString)])
hgetall :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f [(ByteString, ByteString)])
hgetall ByteString
key = [ByteString] -> m (f [(ByteString, ByteString)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"HGETALL", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key]


-- | Set multiple hash fields to multiple values (<http://redis.io/commands/hmset>).
--
-- Deprecated by Redis, consider using 'hset' with multiple field-value pairs.
--
-- Since Redis 2.0.0
hmset
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> NonEmpty (ByteString,ByteString) -- ^ fieldValue
    -> m (f Status)
hmset :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty (ByteString, ByteString) -> m (f Status)
hmset ByteString
key ((ByteString
field,ByteString
value):|[(ByteString, ByteString)]
fieldValues) =
  [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"HMSET"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
fieldByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
valueByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ((ByteString, ByteString) -> [ByteString])
-> [(ByteString, ByteString)] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(ByteString
x,ByteString
y) -> [Item [ByteString]
ByteString
x,Item [ByteString]
ByteString
y]) [(ByteString, ByteString)]
fieldValues)

-- |Intersect multiple sets (<http://redis.io/commands/sinter>).
-- Since Redis 1.0.0
sinter
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ Keys.
    -> m (f [ByteString])
sinter :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [ByteString])
sinter (ByteString
key:|[ByteString]
keys_) = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"SINTER"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
keys_)

-- | /O(1)/
-- Adds all the elements arguments to the HyperLogLog data structure stored at the variable name specified as first argument (<http://redis.io/commands/pfadd>).
-- Since Redis 2.8.9
pfadd
    :: (RedisCtx m f)
    => ByteString -- ^ Key.
    -> NonEmpty ByteString -- ^ Value.
    -> m (f Integer)
pfadd :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
pfadd ByteString
key (ByteString
value:|[ByteString]
values) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"PFADD"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
valueByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
values)

-- | /O(log(N)+M/ with @N@ being the number of elements in the sorted set and @M@ the number of elemnts removed by the operation.
--
-- Remove all members in a sorted set within the given indexes (<http://redis.io/commands/zremrangebyrank>).
--
-- Returns a number of elements that were removed.
--
-- Since Redis 2.0.0
zremrangebyrank
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ start
    -> Integer -- ^ stop
    -> m (f Integer)
zremrangebyrank :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f Integer)
zremrangebyrank ByteString
key Integer
start Integer
stop =
  [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZREMRANGEBYRANK",ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key,Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start,Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
stop]

-- |Remove and return the member with the lowest score in a sorted set (<http://redis.io/commands/zpopmin>).
--
-- Since Redis 5.0.0
zpopmin
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f (Maybe (ByteString, Double)))
zpopmin :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe (ByteString, Double)))
zpopmin ByteString
key = [ByteString] -> m (f (Maybe (ByteString, Double)))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZPOPMIN", Item [ByteString]
ByteString
key]

-- |Remove and return the member with the highest score in a sorted set (<http://redis.io/commands/zpopmax>).
--
-- Since Redis 5.0.0
zpopmax
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f (Maybe (ByteString, Double)))
zpopmax :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe (ByteString, Double)))
zpopmax ByteString
key = [ByteString] -> m (f (Maybe (ByteString, Double)))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZPOPMAX", Item [ByteString]
ByteString
key]

-- |Remove all keys from the current database (<http://redis.io/commands/flushdb>).
-- Since Redis 1.0.0
flushdb
    :: (RedisCtx m f)
    => m (f Status)
flushdb :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
flushdb = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"FLUSHDB"]

-- | /O(1)/ for each element added.
-- Add one or more members to a set (<http://redis.io/commands/sadd>).
-- Since Redis 1.0.0
sadd
    :: (RedisCtx m f)
    => ByteString -- ^ Key where set is stored.
    -> NonEmpty ByteString -- ^ Member to add to the set.
    -> m (f Integer)
sadd :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
sadd ByteString
key NonEmpty ByteString
member = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"SADD"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList ((ByteString -> ByteString)
-> NonEmpty ByteString -> NonEmpty ByteString
forall a b. (a -> b) -> NonEmpty a -> NonEmpty b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode NonEmpty ByteString
member))

-- |Get an element from a list by its index (<http://redis.io/commands/lindex>).
-- Since Redis 1.0.0
lindex
    :: (RedisCtx m f)
    => ByteString -- ^ Key.
    -> Integer -- ^ Index
    -> m (f (Maybe ByteString))
lindex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f (Maybe ByteString))
lindex ByteString
key Integer
index = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"LINDEX",ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key,Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
index]

-- | Prepend one or multiple values to a list (<http://redis.io/commands/lpush>).
-- Since Redis 1.0.0
lpush
    :: (RedisCtx m f)
    => ByteString -- ^ Key
    -> NonEmpty ByteString -- ^ Value
    -> m (f Integer)
lpush :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
lpush ByteString
key (ByteString
value:|[ByteString]
values) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"LPUSH"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
valueByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
values)

-- |Get the length of the value of a hash field (<http://redis.io/commands/hstrlen>).
-- Since Redis 3.2.0
hstrlen
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ field
    -> m (f Integer)
hstrlen :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Integer)
hstrlen ByteString
key ByteString
field = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"HSTRLEN", Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
field]

-- |
-- Move a member from one set to another (<http://redis.io/commands/smove>).
-- Since Redis 1.0.0
smove
    :: (RedisCtx m f)
    => ByteString -- ^ source
    -> ByteString -- ^ destination
    -> ByteString -- ^ member
    -> m (f Bool)
smove :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Bool)
smove ByteString
source ByteString
destination ByteString
member =
  [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SMOVE", Item [ByteString]
ByteString
source, Item [ByteString]
ByteString
destination, Item [ByteString]
ByteString
member]

-- |Get the score associated with the given member in a sorted set (<http://redis.io/commands/zscore>).
-- Since Redis 1.2.0
zscore
    :: (RedisCtx m f)
    => ByteString -- ^ Key.
    -> ByteString -- ^ Member.
    -> m (f (Maybe Double))
zscore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe Double))
zscore ByteString
key ByteString
member = [ByteString] -> m (f (Maybe Double))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZSCORE",ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key,ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
member]

-- |Reset the stats returned by INFO (<http://redis.io/commands/config-resetstat>).
-- Since Redis 2.0.0
configResetstat
    :: (RedisCtx m f)
    => m (f Status)
configResetstat :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
configResetstat  = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"CONFIG",Item [ByteString]
ByteString
"RESETSTAT"]

-- |
-- Return the approximated cardinality of the set(s) observed by the HyperLogLog at key(s) (<http://redis.io/commands/pfcount>).
-- Since Redis 2.8.9
pfcount
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ key
    -> m (f Integer)
pfcount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f Integer)
pfcount (ByteString
key:|[ByteString]
keys_) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"PFCOUNT"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
keys_)

-- | Delete one or more hash fields (<http://redis.io/commands/hdel>).
-- Since Redis 2.0.0
hdel
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> NonEmpty ByteString -- ^ field
    -> m (f Integer)
hdel :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
hdel ByteString
key (ByteString
field:|[ByteString]
fields) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"HDEL"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
fieldByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
fields)

-- |Increment the float value of a key by the given amount (<http://redis.io/commands/incrbyfloat>).
-- Since Redis 2.6.0
incrbyfloat
    :: (RedisCtx m f)
    => ByteString -- ^ Key.
    -> Double -- ^ Increment.
    -> m (f Double)
incrbyfloat :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> m (f Double)
incrbyfloat ByteString
key Double
increment = [ByteString] -> m (f Double)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"INCRBYFLOAT", Item [ByteString]
ByteString
key, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
increment]

-- |Sets or clears the bit at offset in the string value stored at key (<http://redis.io/commands/setbit>).
-- Since Redis 2.2.0
setbit
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ offset
    -> ByteString -- ^ value
    -> m (f Integer)
setbit :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ByteString -> m (f Integer)
setbit ByteString
key Integer
offset ByteString
value = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SETBIT", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
offset, Item [ByteString]
ByteString
value]

-- | Remove all keys from all databases (<http://redis.io/commands/flushall>). Since Redis 1.0.0
flushall
    :: (RedisCtx m f)
    => m (f Status)
flushall :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
flushall  = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"FLUSHALL"]

-- |Increment the integer value of a key by the given amount (<http://redis.io/commands/incrby>).
-- Since Redis 1.0.0
incrby
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ increment
    -> m (f Integer)
incrby :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f Integer)
incrby ByteString
key Integer
increment = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"INCRBY", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
increment]

-- | Return the current server time (<http://redis.io/commands/time>).
-- Since Redis 2.6.0
time
    :: (RedisCtx m f)
    => m (f (Integer,Integer))
time :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f (Integer, Integer))
time  = [ByteString] -> m (f (Integer, Integer))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"TIME"]

-- |Get all the members in a set (<http://redis.io/commands/smembers>). Since Redis 1.0.0
smembers
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f [ByteString])
smembers :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f [ByteString])
smembers ByteString
key = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SMEMBERS", Item [ByteString]
ByteString
key]

-- |Count the number of members in a sorted set between a given lexicographical range (<http://redis.io/commands/zlexcount>).
-- Since Redis 2.8.9
zlexcount
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ min
    -> ByteString -- ^ max
    -> m (f Integer)
zlexcount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Integer)
zlexcount ByteString
key ByteString
min ByteString
max = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZLEXCOUNT", Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
min, Item [ByteString]
ByteString
max]

-- |Add multiple sets (<http://redis.io/commands/sunion>).
-- Since Redis 1.0.0
sunion
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ key
    -> m (f [ByteString])
sunion :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [ByteString])
sunion (ByteString
key:|[ByteString]
keys_) = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"SUNION"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
keys_)

-- |Intersect multiple sets and store the resulting set in a key (<http://redis.io/commands/sinterstore>).
-- Since Redis 1.0.0
sinterstore
    :: (RedisCtx m f)
    => ByteString -- ^ destination
    -> NonEmpty ByteString -- ^ key
    -> m (f Integer)
sinterstore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
sinterstore ByteString
destination (ByteString
key:|[ByteString]
keys_) =
  [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"SINTERSTORE"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
destinationByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
keys_)

-- | Get all the values in a hash (<http://redis.io/commands/hvals>).
-- Since Redis 2.0.0
hvals
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f [ByteString])
hvals :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f [ByteString])
hvals ByteString
key = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"HVALS", Item [ByteString]
ByteString
key]

-- |Set a configuration parameter to the given value (<http://redis.io/commands/config-set>).
-- Since Redis 2.0.0
configSet
    :: (RedisCtx m f)
    => ByteString -- ^ parameter
    -> ByteString -- ^ value
    -> m (f Status)
configSet :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Status)
configSet ByteString
parameter ByteString
value = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"CONFIG",Item [ByteString]
ByteString
"SET", Item [ByteString]
ByteString
parameter, Item [ByteString]
ByteString
value]

-- |Remove all the scripts from the script cache (<http://redis.io/commands/script-flush>).
-- Since Redis 2.6.0
scriptFlush
    :: (RedisCtx m f)
    => m (f Status)
scriptFlush :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
scriptFlush  = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SCRIPT",Item [ByteString]
ByteString
"FLUSH"]

-- |Return the number of keys in the selected database (<http://redis.io/commands/dbsize>).
-- Since Redis 1.0.0
dbsize
    :: (RedisCtx m f)
    => m (f Integer)
dbsize :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Integer)
dbsize  = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"DBSIZE"]

-- |Remove and get the first element in a list (<http://redis.io/commands/lpop>). Since Redis 1.0.0
lpop
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f (Maybe ByteString))
lpop :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
lpop ByteString
key = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"LPOP", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key]

-- |
-- Remove and get the first element in a list (<http://redis.io/commands/lpop>).
-- The reply will consist of up to count elements, depending on the list's length.
-- Since Redis 1.0.0
lpopCount
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer
    -> m (f [ByteString])
lpopCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f [ByteString])
lpopCount ByteString
key Integer
count = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"LPOP", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]

-- |Stop processing commands from clients for some time (<http://redis.io/commands/client-pause>).
-- Since Redis 2.9.50
clientPause
    :: (RedisCtx m f)
    => Integer -- ^ timeout
    -> m (f Status)
clientPause :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> m (f Status)
clientPause Integer
timeout = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"CLIENT",Item [ByteString]
ByteString
"PAUSE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeout]

-- |Set a key's time to live in seconds (<http://redis.io/commands/expire>). Since Redis 1.0.0
expire
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ seconds
    -> m (f Bool)
expire :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f Bool)
expire ByteString
key Integer
seconds = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"EXPIRE", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds]

-- |Get the values of all the given keys (<http://redis.io/commands/mget>).
-- Since Redis 1.0.0
mget
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ key
    -> m (f [Maybe ByteString])
mget :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [Maybe ByteString])
mget (ByteString
key:|[ByteString]
keys_) = [ByteString] -> m (f [Maybe ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"MGET"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
keys_)

-- |
-- Find first bit set or clear in a string (<http://redis.io/commands/bitpos>).
-- Since Redis 2.8.7
bitpos
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ bit
    -> Integer -- ^ start
    -> Integer -- ^ end
    -> m (f Integer)
bitpos :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> Integer -> m (f Integer)
bitpos ByteString
key Integer
bit Integer
start Integer
end = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"BITPOS", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
bit, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
end]

lastsave
    :: (RedisCtx m f)
    => m (f Integer)
lastsave :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Integer)
lastsave  = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([Item [ByteString]
ByteString
"LASTSAVE"] )

-- | Set a key's time to live in milliseconds (<http://redis.io/commands/pexpire>).
-- Since Redis 2.6.0
pexpire
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ milliseconds
    -> m (f Bool)
pexpire :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f Bool)
pexpire ByteString
key Integer
milliseconds = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"PEXPIRE", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds]

-- |Get the list of client connections (<http://redis.io/commands/client-list>). Since Redis 2.4.0
clientList
    :: (RedisCtx m f)
    => m (f [ByteString])
clientList :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f [ByteString])
clientList  = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([Item [ByteString]
ByteString
"CLIENT",Item [ByteString]
ByteString
"LIST"] )

-- |Rename a key, only if the new key does not exist (<http://redis.io/commands/renamenx>). Since Redis 1.0.0
renamenx
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ newkey
    -> m (f Bool)
renamenx :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Bool)
renamenx ByteString
key ByteString
newkey = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"RENAMENX", Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
newkey]

-- |Merge N different HyperLogLogs into a single one (<http://redis.io/commands/pfmerge>). Since Redis 2.8.9
pfmerge
    :: (RedisCtx m f)
    => ByteString -- ^ destkey
    -> [ByteString] -- ^ sourcekey
    -> m (f ByteString)
pfmerge :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> m (f ByteString)
pfmerge ByteString
destkey [ByteString]
sourcekey = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"PFMERGE"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
destkeyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
sourcekey)

-- | Remove elements from a list (<http://redis.io/commands/lrem>). Since Redis 1.0.0
lrem
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ count
    -> ByteString -- ^ value
    -> m (f Integer)
lrem :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ByteString -> m (f Integer)
lrem ByteString
key Integer
count ByteString
value = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"LREM", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count, Item [ByteString]
ByteString
value]

-- |Subtract multiple sets (<http://redis.io/commands/sdiff>). Since Redis 1.0.0
sdiff
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ key
    -> m (f [ByteString])
sdiff :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [ByteString])
sdiff (ByteString
key_:|[ByteString]
keys_) = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"SDIFF"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
key_ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
keys_)

-- |Get the value of a key (<http://redis.io/commands/get>). Since Redis 1.0.0
get
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f (Maybe ByteString))
get :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
get ByteString
key = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([Item [ByteString]
ByteString
"GET"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key] )

-- |Get a substring of the string stored at a key (<http://redis.io/commands/getrange>).
-- Since Redis 2.4.0
getrange
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ start
    -> Integer -- ^ end
    -> m (f ByteString)
getrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f ByteString)
getrange ByteString
key Integer
start Integer
end = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"GETRANGE", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
end]

-- |Subtract multiple sets and store the resulting set in a key (<http://redis.io/commands/sdiffstore>). Since Redis 1.0.0
sdiffstore
    :: (RedisCtx m f)
    => ByteString -- ^ destination
    -> NonEmpty ByteString -- ^ key
    -> m (f Integer)
sdiffstore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
sdiffstore ByteString
destination (ByteString
key_:|[ByteString]
keys_) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"SDIFFSTORE"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
destinationByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
key_ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
keys_)

-- |Count the members in a sorted set with scores within the given values (<http://redis.io/commands/zcount>). Since Redis 2.0.0
zcount
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Double -- ^ min
    -> Double -- ^ max
    -> m (f Integer)
zcount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> Double -> m (f Integer)
zcount ByteString
key Double
min Double
max = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZCOUNT", Item [ByteString]
ByteString
key, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
min, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
max]

-- |Load the specified Lua script into the script cache (<http://redis.io/commands/script-load>). Since Redis 2.6.0
scriptLoad
    :: (RedisCtx m f)
    => ByteString -- ^ script
    -> m (f ByteString)
scriptLoad :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ByteString)
scriptLoad ByteString
script = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SCRIPT",Item [ByteString]
ByteString
"LOAD", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
script]

-- |Set the string value of a key and return its old value (<http://redis.io/commands/getset>). Since Redis 1.0.0
getset
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ value
    -> m (f (Maybe ByteString))
getset :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe ByteString))
getset ByteString
key ByteString
value = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"GETSET", Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
value]

-- |Return a serialized version of the value stored at the specified key (<http://redis.io/commands/dump>). Since Redis 2.6.0
dump
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f ByteString)
dump :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ByteString)
dump ByteString
key = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"DUMP", Item [ByteString]
ByteString
key]

-- |Find all keys matching the given pattern (<http://redis.io/commands/keys>). Since Redis 1.0.0
keys
    :: (RedisCtx m f)
    => ByteString -- ^ pattern
    -> m (f [ByteString])
keys :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f [ByteString])
keys ByteString
pattern = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"KEYS", Item [ByteString]
ByteString
pattern]

-- |Get the value of a configuration parameter (<http://redis.io/commands/config-get>). Since Redis 2.0.0
configGet
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ parameter
    -> m (f [(ByteString,ByteString)])
configGet :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [(ByteString, ByteString)])
configGet (ByteString
parameter:|[ByteString]
parameters) = [ByteString] -> m (f [(ByteString, ByteString)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"CONFIG"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
"GET"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
parameterByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
parameters)

-- |Append one or multiple values to a list (<http://redis.io/commands/rpush>). Since Redis 1.0.0
rpush
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> NonEmpty ByteString -- ^ value
    -> m (f Integer)
rpush :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
rpush ByteString
key (ByteString
value:|[ByteString]
values) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"RPUSH"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
valueByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
values)

-- |Return a random key from the keyspace (<http://redis.io/commands/randomkey>). Since Redis 1.0.0
randomkey
    :: (RedisCtx m f)
    => m (f (Maybe ByteString))
randomkey :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f (Maybe ByteString))
randomkey  = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"RANDOMKEY"]

-- |Set the value of a hash field, only if the field does not exist (<http://redis.io/commands/hsetnx>). Since Redis 2.0.0
hsetnx
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ field
    -> ByteString -- ^ value
    -> m (f Bool)
hsetnx :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Bool)
hsetnx ByteString
key ByteString
field ByteString
value = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"HSETNX", Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
field, Item [ByteString]
ByteString
value]

-- |Set multiple keys to multiple values (<http://redis.io/commands/mset>). Since Redis 1.0.1
mset
    :: (RedisCtx m f)
    => NonEmpty (ByteString,ByteString) -- ^ keyValue
    -> m (f Status)
mset :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty (ByteString, ByteString) -> m (f Status)
mset ((ByteString
key_,ByteString
value):|[(ByteString, ByteString)]
keyValue) =
  [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"MSET"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
key_ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
valueByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ((ByteString, ByteString) -> [ByteString])
-> [(ByteString, ByteString)] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(ByteString
x,ByteString
y) -> [ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
x,ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
y]) [(ByteString, ByteString)]
keyValue)

-- |Set the value and expiration of a key (<http://redis.io/commands/setex>).
-- Regarded as deprected since 2.6 as it can be replaced by SET with the EX argument when
-- migrating or writing new code.
-- Since Redis 2.0.0
setex
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ seconds
    -> ByteString -- ^ value
    -> m (f Status)
setex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ByteString -> m (f Status)
setex ByteString
key Integer
seconds ByteString
value = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SETEX", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds, Item [ByteString]
ByteString
value]

-- |Set the value and expiration in milliseconds of a key (<http://redis.io/commands/psetex>).
-- Condidered deprecated since it can be replaced by SET with the PX argument when migrating or writing new code
-- Since Redis 2.6.0
psetex
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ milliseconds
    -> ByteString -- ^ value
    -> m (f Status)
psetex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ByteString -> m (f Status)
psetex ByteString
key Integer
milliseconds ByteString
value = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"PSETEX", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds, Item [ByteString]
ByteString
value]

-- |Get the number of members in a set (<http://redis.io/commands/scard>). Since Redis 1.0.0
scard
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f Integer)
scard :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
scard ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SCARD", Item [ByteString]
ByteString
key]

-- |Check existence of scripts in the script cache (<http://redis.io/commands/script-exists>). Since Redis 2.6.0
scriptExists
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ script
    -> m (f [Bool])
scriptExists :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [Bool])
scriptExists (ByteString
script:|[ByteString]
scripts) = [ByteString] -> m (f [Bool])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"SCRIPT"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
"EXISTS"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
scriptByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
scripts)

-- |Add multiple sets and store the resulting set in a key (<http://redis.io/commands/sunionstore>). Since Redis 1.0.0
sunionstore
    :: (RedisCtx m f)
    => ByteString -- ^ destination
    -> NonEmpty ByteString -- ^ key
    -> m (f Integer)
sunionstore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
sunionstore ByteString
destination (ByteString
key_:|[ByteString]
keys_) =
  [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"SUNIONSTORE"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
destinationByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
key_ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
keys_)

-- |Remove the expiration from a key (<http://redis.io/commands/persist>). Since Redis 2.2.0
persist
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f Bool)
persist :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Bool)
persist ByteString
key = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"PERSIST", Item [ByteString]
ByteString
key]

-- |Get the length of the value stored in a key (<http://redis.io/commands/strlen>). Since Redis 2.2.0
strlen
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f Integer)
strlen :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
strlen ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"STRLEN", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key]

-- |Prepend a value to a list, only if the list exists (<http://redis.io/commands/lpushx>). Since Redis 2.2.0
lpushx
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> NonEmpty ByteString -- ^ value
    -> m (f Integer)
lpushx :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
lpushx ByteString
key (ByteString
value:|[ByteString]
values) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"LPUSHX"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
valueByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
values)

-- |Set the string value of a hash field (<http://redis.io/commands/hset>).
--
-- This command oveerides keys if they exist in the hash.
--
-- Since Redis 2.0.0
hset
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> NonEmpty (ByteString, ByteString) -- ^ Values.
    -> m (f Integer)
hset :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty (ByteString, ByteString) -> m (f Integer)
hset ByteString
key ((ByteString
field,ByteString
value):|[(ByteString, ByteString)]
fieldValues) =
  [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"HSET"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
fieldByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
valueByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:((ByteString, ByteString) -> [ByteString])
-> [(ByteString, ByteString)] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(ByteString
f,ByteString
v) ->[Item [ByteString]
ByteString
f,Item [ByteString]
ByteString
v]) [(ByteString, ByteString)]
fieldValues)

-- |Pop a value from a list, push it to another list and return it; or block until one is available (<http://redis.io/commands/brpoplpush>).
--
-- Since Redis 6.0 this command considered deprecated: it can be replaced by BLMOVE with the RIGHT and LEFT arguments when migrating or writing new code.
--
-- Since Redis 2.2.0
brpoplpush
    :: (RedisCtx m f)
    => ByteString -- ^ source
    -> ByteString -- ^ destination
    -> Integer -- ^ timeout
    -> m (f (Maybe ByteString))
brpoplpush :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> Integer -> m (f (Maybe ByteString))
brpoplpush ByteString
source ByteString
destination Integer
timeout =
  [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"BRPOPLPUSH", Item [ByteString]
ByteString
source, Item [ByteString]
ByteString
destination, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeout]

-- |Determine the index of a member in a sorted set, with scores ordered from high to low (<http://redis.io/commands/zrevrank>).
-- Since Redis 2.0.0
zrevrank
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ member
    -> m (f (Maybe Integer))
zrevrank :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe Integer))
zrevrank ByteString
key ByteString
member = [ByteString] -> m (f (Maybe Integer))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZREVRANK", Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
member]

zrevrankWithScore
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ member
    -> m (f (Maybe (Integer, Double)))
zrevrankWithScore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe (Integer, Double)))
zrevrankWithScore ByteString
key ByteString
member = [ByteString] -> m (f (Maybe (Integer, Double)))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZREVRANK", Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
member]

-- |Kill the script currently in execution (<http://redis.io/commands/script-kill>). Since Redis 2.6.0
scriptKill
    :: (RedisCtx m f)
    => m (f Status)
scriptKill :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
scriptKill  = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SCRIPT",Item [ByteString]
ByteString
"KILL"]

-- |Overwrite part of a string at key starting at the specified offset (<http://redis.io/commands/setrange>).
--
-- Returns the lenght of the string after it was modified.
--
-- Since Redis 2.2.0
setrange
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ offset
    -> ByteString -- ^ value
    -> m (f Integer)
setrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ByteString -> m (f Integer)
setrange ByteString
key Integer
offset ByteString
value = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SETRANGE", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
offset, Item [ByteString]
ByteString
value]

-- | Delete a key (<http://redis.io/commands/del>).
-- Returns a number of keys that were removed.
-- Since Redis 1.0.0
del
    :: (RedisCtx m f)
    => NonEmpty ByteString -- ^ List of keys to delete.
    -> m (f Integer)
del :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f Integer)
del (ByteString
key:|[ByteString]
rest) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"DEL"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
rest)

-- |Increment the float value of a hash field by the given amount (<http://redis.io/commands/hincrbyfloat>).
-- Since Redis 2.6.0
hincrbyfloat
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ field
    -> Double -- ^ increment
    -> m (f Double)
hincrbyfloat :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> Double -> m (f Double)
hincrbyfloat ByteString
key ByteString
field Double
increment = [ByteString] -> m (f Double)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"HINCRBYFLOAT", Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
field, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
increment]

-- | Increment the integer value of a hash field by the given number (<http://redis.io/commands/hincrby>). Since Redis 2.0.0
hincrby
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ field
    -> Int64 -- ^ increment
    -> m (f Int64)
hincrby :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> Int64 -> m (f Int64)
hincrby ByteString
key ByteString
field Int64
increment = [ByteString] -> m (f Int64)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"HINCRBY", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key, ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
field, Int64 -> ByteString
forall a. RedisArg a => a -> ByteString
encode Int64
increment]

-- | O(log(N)+M) with @N@ being thee number of elements in thee sorted set and @M@ the number
-- of elements removed by the operation.
--
-- Remove all members in a sorted set between the given lexicographical range (<http://redis.io/commands/zremrangebylex>).
--
-- Returns number of elements that were removed.
--
-- Since Redis 2.8.9
zremrangebylex
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ min
    -> ByteString -- ^ max
    -> m (f Integer)
zremrangebylex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Integer)
zremrangebylex ByteString
key ByteString
min ByteString
max = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([Item [ByteString]
ByteString
"ZREMRANGEBYLEX"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
min] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
max] )

-- |Remove and get the last element in a list (<http://redis.io/commands/rpop>).
-- Since Redis 1.0.0
rpop
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f (Maybe ByteString))
rpop :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
rpop ByteString
key = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"RPOP", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key]

-- |Remove and get the last element in a list (<http://redis.io/commands/rpop>).
-- The reply will consist of up to count elements, depending on the list's length.
-- Result will have no more than @N@ arguments.
--
-- Since Redis 1.0.0
rpopCount
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer
    -> m (f [ByteString])
rpopCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f [ByteString])
rpopCount ByteString
key Integer
count = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([Item [ByteString]
ByteString
"RPOP",Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count] )

-- |Rename a key (<http://redis.io/commands/rename>). Since Redis 1.0.0
--
-- Does not return a error even if newkey existed.
rename
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ newkey
    -> m (f Status)
rename :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Status)
rename ByteString
key ByteString
newkey = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"RENAME",  ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key, ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
newkey]

-- | /O(M*log(N))/ with @N@ number of elements in the sorted set, @M@ number of elements to be
-- removed.
--
-- Removes one or more members from a sorted set (<http://redis.io/commands/zrem>).
--
-- Since Redis 1.2.0
zrem
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> NonEmpty ByteString -- ^ member
    -> m (f Integer)
zrem :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
zrem ByteString
key (ByteString
member:|[ByteString]
members) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"ZREM"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
memberByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
members)

-- |Determine if a hash field exists (<http://redis.io/commands/hexists>).
-- Since Redis 2.0.0
hexists
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ field
    -> m (f Bool)
hexists :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Bool)
hexists ByteString
key ByteString
field = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"HEXISTS", Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
field]

-- |Get the current connection ID (<http://redis.io/commands/client-id>). Since Redis 5.0.0
clientId
    :: (RedisCtx m f)
    => m (f Integer)
clientId :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Integer)
clientId  = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"CLIENT",Item [ByteString]
ByteString
"ID"]

-- |Get the current connection name (<http://redis.io/commands/client-getname>). Since Redis 2.6.9
clientGetname
    :: (RedisCtx m f)
    => m (f (Maybe ByteString))
clientGetname :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f (Maybe ByteString))
clientGetname  = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"CLIENT",Item [ByteString]
ByteString
"GETNAME"]

-- |Rewrite the configuration file with the in memory configuration (<http://redis.io/commands/config-rewrite>). Since Redis 2.8.0
configRewrite
    :: (RedisCtx m f)
    => m (f Status)
configRewrite :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
configRewrite  = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"CONFIG",Item [ByteString]
ByteString
"REWRITE"]

-- |Decrement the integer value of a key by one (<http://redis.io/commands/decr>).
-- Since Redis 1.0.0
decr
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f Integer)
decr :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
decr ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"DECR", Item [ByteString]
ByteString
key]

-- |Get the values of all the given hash fields (<http://redis.io/commands/hmget>).
-- Since Redis 2.0.0
hmget
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> NonEmpty ByteString -- ^ field
    -> m (f [Maybe ByteString])
hmget :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f [Maybe ByteString])
hmget ByteString
key (ByteString
field:|[ByteString]
fields) = [ByteString] -> m (f [Maybe ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"HMGET"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
fieldByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
fields)

-- |Get a range of elements from a list (<http://redis.io/commands/lrange>). Since Redis 1.0.0
lrange
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ start
    -> Integer -- ^ stop
    -> m (f [ByteString])
lrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f [ByteString])
lrange ByteString
key Integer
start Integer
stop = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"LRANGE", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
stop]

-- |Decrement the integer value of a key by the given number (<http://redis.io/commands/decrby>).
-- Since Redis 1.0.0
decrby
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ decrement
    -> m (f Integer)
decrby :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f Integer)
decrby ByteString
key Integer
decrement = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"DECRBY",Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
decrement]

-- |Get the length of a list (<http://redis.io/commands/llen>). Since Redis 1.0.0
llen
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f Integer)
llen :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
llen ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"LLEN", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key]

-- | /O(1)/ Append a value to a key (<http://redis.io/commands/append>). Since Redis 2.0.0
append
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ value
    -> m (f Integer)
append :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Integer)
append ByteString
key ByteString
value = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"APPEND", Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
value]

-- |Increment the integer value of a key by one (<http://redis.io/commands/incr>). Since Redis 1.0.0
incr
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f Integer)
incr :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
incr ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"INCR", Item [ByteString]
ByteString
key]

-- |Get the value of a hash field (<http://redis.io/commands/hget>). Since Redis 2.0.0
hget
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> ByteString -- ^ field
    -> m (f (Maybe ByteString))
hget :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe ByteString))
hget ByteString
key ByteString
field = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"HGET",Item [ByteString]
ByteString
key,Item [ByteString]
ByteString
field]

-- |Set the expiration for a key as a UNIX timestamp specified in milliseconds (<http://redis.io/commands/pexpireat>). Since Redis 2.6.0
pexpireat
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ millisecondsTimestamp
    -> m (f Bool)
pexpireat :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f Bool)
pexpireat ByteString
key Integer
millisecondsTimestamp = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"PEXPIREAT", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
millisecondsTimestamp]

-- | Trim a list to the specified range (<http://redis.io/commands/ltrim>).
-- Since Redis 1.0.0
ltrim
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ start
    -> Integer -- ^ stop
    -> m (f Status)
ltrim :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f Status)
ltrim ByteString
key Integer
start Integer
stop = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"LTRIM", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
stop]

-- | /O(1)/
-- Get the number of members in a sorted set (<http://redis.io/commands/zcard>).
-- Since Redis 1.2.0
zcard
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> m (f Integer)
zcard :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
zcard ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ZCARD", Item [ByteString]
ByteString
key]

-- | Set the value of an element in a list by its index (<http://redis.io/commands/lset>).
-- Since Redis 1.0.0
lset
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ index
    -> ByteString -- ^ value
    -> m (f Status)
lset :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ByteString -> m (f Status)
lset ByteString
key Integer
index ByteString
value = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"LSET", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
index, Item [ByteString]
ByteString
value]

-- | Set the expiration for a key as a UNIX timestamp (<http://redis.io/commands/expireat>).
-- Since Redis 1.2.0
expireat
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ timestamp
    -> m (f Bool)
expireat :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f Bool)
expireat ByteString
key Integer
timestamp = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"EXPIREAT", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timestamp]

-- | Synchronously save the dataset to disk (<http://redis.io/commands/save>).
-- Since Redis 1.0.0
save
    :: (RedisCtx m f)
    => m (f Status)
save :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
save  = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SAVE"]

-- |
-- Move a key to another database (<http://redis.io/commands/move>).
-- Since Redis 1.0.0
move
    :: (RedisCtx m f)
    => ByteString -- ^ key
    -> Integer -- ^ db
    -> m (f Bool)
move :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f Bool)
move ByteString
key Integer
db = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"MOVE", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
db]

-- |
-- Returns the bit value at offset in the string value stored at key (<http://redis.io/commands/getbit>). Since Redis 2.2.0
getbit
    :: (RedisCtx m f)
    => ByteString -- ^ Key.
    -> Integer -- ^ Offset.
    -> m (f Integer)
getbit :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f Integer)
getbit ByteString
key Integer
offset = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"GETBIT", Item [ByteString]
ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
offset]

-- |Set multiple keys to multiple values, only if none of the keys exist (<http://redis.io/commands/msetnx>).
-- Since Redis 1.0.1
msetnx
    :: (RedisCtx m f)
    => NonEmpty (ByteString,ByteString) -- ^ keyValue
    -> m (f Bool)
msetnx :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty (ByteString, ByteString) -> m (f Bool)
msetnx ((ByteString
key,ByteString
value):|[(ByteString, ByteString)]
keysValues) =
  [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"MSETNX"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
valueByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:((ByteString, ByteString) -> [ByteString])
-> [(ByteString, ByteString)] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(ByteString
x,ByteString
y) -> [ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
x,ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
y]) [(ByteString, ByteString)]
keysValues)

-- |Get array of specific Redis command details (<http://redis.io/commands/command-info>).
-- Since Redis 2.8.13
commandInfo
    :: (RedisCtx m f)
    => [ByteString] -- ^ commandName
    -> m (f [ByteString])
commandInfo :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
[ByteString] -> m (f [ByteString])
commandInfo [ByteString]
commandName = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"COMMAND"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
"INFO"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:(ByteString -> ByteString) -> [ByteString] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode [ByteString]
commandName )

-- | Close the connection (<http://redis.io/commands/quit>). Since Redis 1.0.0
quit
    :: (RedisCtx m f)
    => m (f Status)
quit :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
quit  = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"QUIT"]

-- |Remove and get the first element in a list, or block until one is available (<http://redis.io/commands/blpop>). Since Redis 2.0.0
blpop
    :: (RedisCtx m f)
    => [ByteString] -- ^ key
    -> Integer -- ^ timeout
    -> m (f (Maybe (ByteString,ByteString)))
blpop :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
[ByteString] -> Integer -> m (f (Maybe (ByteString, ByteString)))
blpop [ByteString]
keys_ Integer
timeout = [ByteString] -> m (f (Maybe (ByteString, ByteString)))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"BLPOP"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
keys_ [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeout] )

-- |Remove and get the first element in a list, or block until one is available (<http://redis.io/commands/blpop>). Since Redis 6.0.0
blpopFloat
    :: (RedisCtx m f)
    => [ByteString] -- ^ key
    -> Integer -- ^ timeout
    -> m (f (Maybe (ByteString,ByteString)))
blpopFloat :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
[ByteString] -> Integer -> m (f (Maybe (ByteString, ByteString)))
blpopFloat [ByteString]
keys_ Integer
timeout = [ByteString] -> m (f (Maybe (ByteString, ByteString)))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"BLPOP"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
keys_ [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeout] )

-- | /O(N)/ where @N@ is the number of members to be removed.
-- Remove one or more members from a set (<http://redis.io/commands/srem>).
--
-- Returns the number of members that were removed from the seet, not including non
-- existing elements.
--
-- Since Redis 1.0.0
srem
    :: (RedisCtx m f)
    => ByteString -- ^ Key of the set.
    -> NonEmpty ByteString -- ^ List of members to be removed.
    -> m (f Integer)
srem :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
srem ByteString
key (ByteString
member:|[ByteString]
members) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"SREM"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
memberByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
members)

-- |Echo the given string (<http://redis.io/commands/echo>). Since Redis 1.0.0
echo
    :: (RedisCtx m f)
    => ByteString -- ^ message
    -> m (f ByteString)
echo :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ByteString)
echo ByteString
message = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"ECHO", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
message]

-- |Determine if a given value is a member of a set (<http://redis.io/commands/sismember>).
--  Since Redis 1.0.0
sismember
    :: (RedisCtx m f)
    => ByteString -- ^ Key.
    -> ByteString -- ^ member
    -> m (f Bool)
sismember :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Bool)
sismember ByteString
key ByteString
member = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [Item [ByteString]
ByteString
"SISMEMBER",Item [ByteString]
ByteString
key, Item [ByteString]
ByteString
member]

-- $autoclaim
--
-- Family of the commands related to the autoclaim command in redis, they provide an
-- ability to claim messages that are not processed for a long time.
--
-- 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\>.
--
-- Redis @xautoclaim@ command is split info `xautoclaim`, `xautoclaimOpts`, `xautoclaimJustIds`
-- `xautoclaimJustIdsOpt` functions.
--
-- All commands are available since Redis 7.0

-- $xpending
-- The Redis @XPENDING@ command is split into 'xpendingSummary' and 'xpendingDetail'.

-- $xgroupCreate
-- Create a consumer group. The redis command @XGROUP CREATE@ is split up into 'xgroupCreate', 'xgroupCreateOpts'.

-- $xgroupSetId
-- Sets last delivered ID for a consumer group. The redis command @XGROUP SETID@ is split up into 'xgroupSetId' and 'xgroupSetIdOpts' methods.


-- $auth
-- Authenticate to the server (<http://redis.io/commands/auth>). Since Redis 1.0.0