{-# LANGUAGE CPP, OverloadedStrings, RecordWildCards, FlexibleContexts #-}
module Database.Redis.ManualCommands where
import Prelude hiding (min, max)
import Data.ByteString (ByteString, empty, append)
import qualified Data.ByteString.Char8 as Char8
import qualified Data.ByteString as BS
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NE
import Data.Maybe (maybeToList, catMaybes, fromMaybe)
#if __GLASGOW_HASKELL__ < 808
import Data.Semigroup ((<>))
#endif
import Database.Redis.Core
import Database.Redis.Protocol
import Database.Redis.Types
import qualified Database.Redis.Cluster.Command as CMD
objectRefcount
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
objectRefcount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
objectRefcount ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"OBJECT", ByteString
"refcount", ByteString
key]
objectIdletime
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
objectIdletime :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
objectIdletime ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"OBJECT", ByteString
"idletime", ByteString
key]
objectEncoding
:: (RedisCtx m f)
=> ByteString
-> m (f ByteString)
objectEncoding :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ByteString)
objectEncoding ByteString
key = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"OBJECT", ByteString
"encoding", ByteString
key]
linsertBefore
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> m (f Integer)
linsertBefore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Integer)
linsertBefore ByteString
key ByteString
pivot ByteString
value =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"LINSERT", ByteString
key, ByteString
"BEFORE", ByteString
pivot, ByteString
value]
linsertAfter
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> m (f Integer)
linsertAfter :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Integer)
linsertAfter ByteString
key ByteString
pivot ByteString
value =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"LINSERT", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key, ByteString
"AFTER", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
pivot, ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
value]
data ListDirection = ListLeft | ListRight deriving (Int -> ListDirection -> ShowS
[ListDirection] -> ShowS
ListDirection -> String
(Int -> ListDirection -> ShowS)
-> (ListDirection -> String)
-> ([ListDirection] -> ShowS)
-> Show ListDirection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ListDirection -> ShowS
showsPrec :: Int -> ListDirection -> ShowS
$cshow :: ListDirection -> String
show :: ListDirection -> String
$cshowList :: [ListDirection] -> ShowS
showList :: [ListDirection] -> ShowS
Show, ListDirection -> ListDirection -> Bool
(ListDirection -> ListDirection -> Bool)
-> (ListDirection -> ListDirection -> Bool) -> Eq ListDirection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListDirection -> ListDirection -> Bool
== :: ListDirection -> ListDirection -> Bool
$c/= :: ListDirection -> ListDirection -> Bool
/= :: ListDirection -> ListDirection -> Bool
Eq)
instance RedisArg ListDirection where
encode :: ListDirection -> ByteString
encode ListDirection
ListLeft = ByteString
"LEFT"
encode ListDirection
ListRight = ByteString
"RIGHT"
data LPosOpts = LPosOpts
{ LPosOpts -> Maybe Integer
lposRank :: Maybe Integer
, LPosOpts -> Maybe Integer
lposMaxlen :: Maybe Integer
} deriving (Int -> LPosOpts -> ShowS
[LPosOpts] -> ShowS
LPosOpts -> String
(Int -> LPosOpts -> ShowS)
-> (LPosOpts -> String) -> ([LPosOpts] -> ShowS) -> Show LPosOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LPosOpts -> ShowS
showsPrec :: Int -> LPosOpts -> ShowS
$cshow :: LPosOpts -> String
show :: LPosOpts -> String
$cshowList :: [LPosOpts] -> ShowS
showList :: [LPosOpts] -> ShowS
Show, LPosOpts -> LPosOpts -> Bool
(LPosOpts -> LPosOpts -> Bool)
-> (LPosOpts -> LPosOpts -> Bool) -> Eq LPosOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LPosOpts -> LPosOpts -> Bool
== :: LPosOpts -> LPosOpts -> Bool
$c/= :: LPosOpts -> LPosOpts -> Bool
/= :: LPosOpts -> LPosOpts -> Bool
Eq)
defaultLPosOpts :: LPosOpts
defaultLPosOpts :: LPosOpts
defaultLPosOpts = LPosOpts
{ lposRank :: Maybe Integer
lposRank = Maybe Integer
forall a. Maybe a
Nothing
, lposMaxlen :: Maybe Integer
lposMaxlen = Maybe Integer
forall a. Maybe a
Nothing
}
lpos
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f (Maybe Integer))
lpos :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe Integer))
lpos ByteString
key ByteString
element = ByteString -> ByteString -> LPosOpts -> m (f (Maybe Integer))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> LPosOpts -> m (f (Maybe Integer))
lposOpts ByteString
key ByteString
element LPosOpts
defaultLPosOpts
lposOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> LPosOpts
-> m (f (Maybe Integer))
lposOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> LPosOpts -> m (f (Maybe Integer))
lposOpts ByteString
key ByteString
element LPosOpts
opts =
[ByteString] -> m (f (Maybe Integer))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe Integer)))
-> [ByteString] -> m (f (Maybe Integer))
forall a b. (a -> b) -> a -> b
$ [ByteString
"LPOS", ByteString
key, ByteString
element] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ LPosOpts -> [ByteString]
lposOptsToArgs LPosOpts
opts
lposCount
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> Integer
-> m (f [Integer])
lposCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> Integer -> m (f [Integer])
lposCount ByteString
key ByteString
element Integer
count = ByteString -> ByteString -> Integer -> LPosOpts -> m (f [Integer])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> Integer -> LPosOpts -> m (f [Integer])
lposCountOpts ByteString
key ByteString
element Integer
count LPosOpts
defaultLPosOpts
lposCountOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> Integer
-> LPosOpts
-> m (f [Integer])
lposCountOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> Integer -> LPosOpts -> m (f [Integer])
lposCountOpts ByteString
key ByteString
element Integer
count LPosOpts
opts =
[ByteString] -> m (f [Integer])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [Integer]))
-> [ByteString] -> m (f [Integer])
forall a b. (a -> b) -> a -> b
$ [ByteString
"LPOS", ByteString
key, ByteString
element] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
rankArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
maxlenArg
where
([ByteString]
rankArg, [ByteString]
maxlenArg) = LPosOpts -> ([ByteString], [ByteString])
lposOptsParts LPosOpts
opts
lposOptsToArgs :: LPosOpts -> [ByteString]
lposOptsToArgs :: LPosOpts -> [ByteString]
lposOptsToArgs LPosOpts
opts =
[ByteString]
rankArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
maxlenArg
where
([ByteString]
rankArg, [ByteString]
maxlenArg) = LPosOpts -> ([ByteString], [ByteString])
lposOptsParts LPosOpts
opts
lposOptsParts :: LPosOpts -> ([ByteString], [ByteString])
lposOptsParts :: LPosOpts -> ([ByteString], [ByteString])
lposOptsParts LPosOpts{Maybe Integer
lposRank :: LPosOpts -> Maybe Integer
lposMaxlen :: LPosOpts -> Maybe Integer
lposRank :: Maybe Integer
lposMaxlen :: Maybe Integer
..} =
( [ByteString]
rankArg
, [ByteString]
maxlenArg
)
where
rankArg :: [ByteString]
rankArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
rank -> [ByteString
"RANK", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
rank]) Maybe Integer
lposRank
maxlenArg :: [ByteString]
maxlenArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
maxlen -> [ByteString
"MAXLEN", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
maxlen]) Maybe Integer
lposMaxlen
lmove
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ListDirection
-> ListDirection
-> m (f (Maybe ByteString))
lmove :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ListDirection
-> ListDirection
-> m (f (Maybe ByteString))
lmove ByteString
source ByteString
destination ListDirection
from ListDirection
to =
[ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"LMOVE", ByteString
source, ByteString
destination, ListDirection -> ByteString
forall a. RedisArg a => a -> ByteString
encode ListDirection
from, ListDirection -> ByteString
forall a. RedisArg a => a -> ByteString
encode ListDirection
to]
blmove
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ListDirection
-> ListDirection
-> Integer
-> m (f (Maybe ByteString))
blmove :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ListDirection
-> ListDirection
-> Integer
-> m (f (Maybe ByteString))
blmove ByteString
source ByteString
destination ListDirection
from ListDirection
to Integer
timeout =
[ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"BLMOVE", ByteString
source, ByteString
destination, ListDirection -> ByteString
forall a. RedisArg a => a -> ByteString
encode ListDirection
from, ListDirection -> ByteString
forall a. RedisArg a => a -> ByteString
encode ListDirection
to, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeout]
lmpop
:: (RedisCtx m f)
=> NonEmpty ByteString
-> ListDirection
-> m (f (Maybe (ByteString, [ByteString])))
lmpop :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> ListDirection -> m (f (Maybe (ByteString, [ByteString])))
lmpop NonEmpty ByteString
keys ListDirection
direction = NonEmpty ByteString
-> ListDirection
-> Integer
-> m (f (Maybe (ByteString, [ByteString])))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> ListDirection
-> Integer
-> m (f (Maybe (ByteString, [ByteString])))
lmpopCount NonEmpty ByteString
keys ListDirection
direction Integer
1
lmpopCount
:: (RedisCtx m f)
=> NonEmpty ByteString
-> ListDirection
-> Integer
-> m (f (Maybe (ByteString, [ByteString])))
lmpopCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> ListDirection
-> Integer
-> m (f (Maybe (ByteString, [ByteString])))
lmpopCount NonEmpty ByteString
keys ListDirection
direction Integer
count =
[ByteString] -> m (f (Maybe (ByteString, [ByteString])))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe (ByteString, [ByteString]))))
-> [ByteString] -> m (f (Maybe (ByteString, [ByteString])))
forall a b. (a -> b) -> a -> b
$ [ByteString
"LMPOP", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty ByteString -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty ByteString
keys)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ListDirection -> ByteString
forall a. RedisArg a => a -> ByteString
encode ListDirection
direction, ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
blmpop
:: (RedisCtx m f)
=> Double
-> NonEmpty ByteString
-> ListDirection
-> m (f (Maybe (ByteString, [ByteString])))
blmpop :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Double
-> NonEmpty ByteString
-> ListDirection
-> m (f (Maybe (ByteString, [ByteString])))
blmpop Double
timeout NonEmpty ByteString
keys ListDirection
direction = Double
-> NonEmpty ByteString
-> ListDirection
-> Integer
-> m (f (Maybe (ByteString, [ByteString])))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Double
-> NonEmpty ByteString
-> ListDirection
-> Integer
-> m (f (Maybe (ByteString, [ByteString])))
blmpopCount Double
timeout NonEmpty ByteString
keys ListDirection
direction Integer
1
blmpopCount
:: (RedisCtx m f)
=> Double
-> NonEmpty ByteString
-> ListDirection
-> Integer
-> m (f (Maybe (ByteString, [ByteString])))
blmpopCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Double
-> NonEmpty ByteString
-> ListDirection
-> Integer
-> m (f (Maybe (ByteString, [ByteString])))
blmpopCount Double
timeout NonEmpty ByteString
keys ListDirection
direction Integer
count =
[ByteString] -> m (f (Maybe (ByteString, [ByteString])))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe (ByteString, [ByteString]))))
-> [ByteString] -> m (f (Maybe (ByteString, [ByteString])))
forall a b. (a -> b) -> a -> b
$ [ByteString
"BLMPOP", Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
timeout, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty ByteString -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty ByteString
keys)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ListDirection -> ByteString
forall a. RedisArg a => a -> ByteString
encode ListDirection
direction, ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
getType
:: (RedisCtx m f)
=> ByteString
-> m (f RedisType)
getType :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f RedisType)
getType ByteString
key = [ByteString] -> m (f RedisType)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"TYPE", ByteString
key]
data Slowlog = Slowlog
{ Slowlog -> Integer
slowlogId :: Integer
, Slowlog -> Integer
slowlogTimestamp :: Integer
, Slowlog -> Integer
slowlogMicros :: Integer
, Slowlog -> [ByteString]
slowlogCmd :: [ByteString]
, Slowlog -> Maybe ByteString
slowlogClientIpAndPort :: Maybe ByteString
, Slowlog -> Maybe ByteString
slowlogClientName :: Maybe ByteString
} deriving (Int -> Slowlog -> ShowS
[Slowlog] -> ShowS
Slowlog -> String
(Int -> Slowlog -> ShowS)
-> (Slowlog -> String) -> ([Slowlog] -> ShowS) -> Show Slowlog
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Slowlog -> ShowS
showsPrec :: Int -> Slowlog -> ShowS
$cshow :: Slowlog -> String
show :: Slowlog -> String
$cshowList :: [Slowlog] -> ShowS
showList :: [Slowlog] -> ShowS
Show, Slowlog -> Slowlog -> Bool
(Slowlog -> Slowlog -> Bool)
-> (Slowlog -> Slowlog -> Bool) -> Eq Slowlog
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Slowlog -> Slowlog -> Bool
== :: Slowlog -> Slowlog -> Bool
$c/= :: Slowlog -> Slowlog -> Bool
/= :: Slowlog -> Slowlog -> Bool
Eq)
instance RedisResult Slowlog where
decode :: Reply -> Either Reply Slowlog
decode (MultiBulk (Just [Reply
logId,Reply
timestamp,Reply
micros,Reply
cmd])) = do
slowlogId <- Reply -> Either Reply Integer
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
logId
slowlogTimestamp <- decode timestamp
slowlogMicros <- decode micros
slowlogCmd <- decode cmd
let slowlogClientIpAndPort = Maybe a
forall a. Maybe a
Nothing
slowlogClientName = Maybe a
forall a. Maybe a
Nothing
return Slowlog{..}
decode (MultiBulk (Just [Reply
logId,Reply
timestamp,Reply
micros,Reply
cmd,Reply
ip,Reply
cname])) = do
slowlogId <- Reply -> Either Reply Integer
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
logId
slowlogTimestamp <- decode timestamp
slowlogMicros <- decode micros
slowlogCmd <- decode cmd
slowlogClientIpAndPort <- Just <$> decode ip
slowlogClientName <- Just <$> decode cname
return Slowlog{..}
decode Reply
r = Reply -> Either Reply Slowlog
forall a b. a -> Either a b
Left Reply
r
slowlogGet
:: (RedisCtx m f)
=> Integer
-> m (f [Slowlog])
slowlogGet :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> m (f [Slowlog])
slowlogGet Integer
n = [ByteString] -> m (f [Slowlog])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SLOWLOG", ByteString
"GET", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
n]
slowlogLen :: (RedisCtx m f) => m (f Integer)
slowlogLen :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Integer)
slowlogLen = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SLOWLOG", ByteString
"LEN"]
slowlogReset :: (RedisCtx m f) => m (f Status)
slowlogReset :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
slowlogReset = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SLOWLOG", ByteString
"RESET"]
zrange
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> m (f [ByteString])
zrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f [ByteString])
zrange ByteString
key Integer
start Integer
stop =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANGE", 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]
zrangeWithscores
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> m (f [(ByteString, Double)])
zrangeWithscores :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f [(ByteString, Double)])
zrangeWithscores ByteString
key Integer
start Integer
stop =
[ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANGE", 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, ByteString
"WITHSCORES"]
zrevrange
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> m (f [ByteString])
zrevrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f [ByteString])
zrevrange ByteString
key Integer
start Integer
stop =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZREVRANGE", 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]
zrevrangeWithscores
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> m (f [(ByteString, Double)])
zrevrangeWithscores :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f [(ByteString, Double)])
zrevrangeWithscores ByteString
key Integer
start Integer
stop =
[ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZREVRANGE", 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
,ByteString
"WITHSCORES"]
zrangebyscore
:: (RedisCtx m f)
=> ByteString
-> Double
-> Double
-> m (f [ByteString])
zrangebyscore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> Double -> m (f [ByteString])
zrangebyscore ByteString
key Double
min Double
max =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANGEBYSCORE", 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]
zrangebyscoreWithscores
:: (RedisCtx m f)
=> ByteString
-> Double
-> Double
-> m (f [(ByteString, Double)])
zrangebyscoreWithscores :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> Double -> m (f [(ByteString, Double)])
zrangebyscoreWithscores ByteString
key Double
min Double
max =
[ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANGEBYSCORE", 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
,ByteString
"WITHSCORES"]
zrangebyscoreLimit
:: (RedisCtx m f)
=> ByteString
-> Double
-> Double
-> Integer
-> Integer
-> m (f [ByteString])
zrangebyscoreLimit :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Double -> Double -> Integer -> Integer -> m (f [ByteString])
zrangebyscoreLimit ByteString
key Double
min Double
max Integer
offset Integer
count =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANGEBYSCORE", 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
,ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
offset, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
zrangebyscoreWithscoresLimit
:: (RedisCtx m f)
=> ByteString
-> Double
-> Double
-> Integer
-> Integer
-> m (f [(ByteString, Double)])
zrangebyscoreWithscoresLimit :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Double
-> Double
-> Integer
-> Integer
-> m (f [(ByteString, Double)])
zrangebyscoreWithscoresLimit ByteString
key Double
min Double
max Integer
offset Integer
count =
[ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANGEBYSCORE", 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
,ByteString
"WITHSCORES",ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
offset, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
zrevrangebyscore
:: (RedisCtx m f)
=> ByteString
-> Double
-> Double
-> m (f [ByteString])
zrevrangebyscore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> Double -> m (f [ByteString])
zrevrangebyscore ByteString
key Double
min Double
max =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZREVRANGEBYSCORE", 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]
zrevrangebyscoreWithscores
:: (RedisCtx m f)
=> ByteString
-> Double
-> Double
-> m (f [(ByteString, Double)])
zrevrangebyscoreWithscores :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> Double -> m (f [(ByteString, Double)])
zrevrangebyscoreWithscores ByteString
key Double
min Double
max =
[ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZREVRANGEBYSCORE", 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
,ByteString
"WITHSCORES"]
zrevrangebyscoreLimit
:: (RedisCtx m f)
=> ByteString
-> Double
-> Double
-> Integer
-> Integer
-> m (f [ByteString])
zrevrangebyscoreLimit :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Double -> Double -> Integer -> Integer -> m (f [ByteString])
zrevrangebyscoreLimit ByteString
key Double
min Double
max Integer
offset Integer
count =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZREVRANGEBYSCORE", 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
,ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
offset, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
zrevrangebyscoreWithscoresLimit
:: (RedisCtx m f)
=> ByteString
-> Double
-> Double
-> Integer
-> Integer
-> m (f [(ByteString, Double)])
zrevrangebyscoreWithscoresLimit :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Double
-> Double
-> Integer
-> Integer
-> m (f [(ByteString, Double)])
zrevrangebyscoreWithscoresLimit ByteString
key Double
min Double
max Integer
offset Integer
count =
[ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZREVRANGEBYSCORE", 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
,ByteString
"WITHSCORES",ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
offset, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
data SortOpts = SortOpts
{ SortOpts -> Maybe ByteString
sortBy :: Maybe ByteString
, SortOpts -> (Integer, Integer)
sortLimit :: (Integer,Integer)
, SortOpts -> [ByteString]
sortGet :: [ByteString]
, SortOpts -> SortOrder
sortOrder :: SortOrder
, SortOpts -> Bool
sortAlpha :: Bool
} deriving (Int -> SortOpts -> ShowS
[SortOpts] -> ShowS
SortOpts -> String
(Int -> SortOpts -> ShowS)
-> (SortOpts -> String) -> ([SortOpts] -> ShowS) -> Show SortOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SortOpts -> ShowS
showsPrec :: Int -> SortOpts -> ShowS
$cshow :: SortOpts -> String
show :: SortOpts -> String
$cshowList :: [SortOpts] -> ShowS
showList :: [SortOpts] -> ShowS
Show, SortOpts -> SortOpts -> Bool
(SortOpts -> SortOpts -> Bool)
-> (SortOpts -> SortOpts -> Bool) -> Eq SortOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SortOpts -> SortOpts -> Bool
== :: SortOpts -> SortOpts -> Bool
$c/= :: SortOpts -> SortOpts -> Bool
/= :: SortOpts -> SortOpts -> Bool
Eq)
defaultSortOpts :: SortOpts
defaultSortOpts :: SortOpts
defaultSortOpts = SortOpts
{ sortBy :: Maybe ByteString
sortBy = Maybe ByteString
forall a. Maybe a
Nothing
, sortLimit :: (Integer, Integer)
sortLimit = (Integer
0,-Integer
1)
, sortGet :: [ByteString]
sortGet = []
, sortOrder :: SortOrder
sortOrder = SortOrder
Asc
, sortAlpha :: Bool
sortAlpha = Bool
False
}
data SortOrder = Asc | Desc deriving (Int -> SortOrder -> ShowS
[SortOrder] -> ShowS
SortOrder -> String
(Int -> SortOrder -> ShowS)
-> (SortOrder -> String)
-> ([SortOrder] -> ShowS)
-> Show SortOrder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SortOrder -> ShowS
showsPrec :: Int -> SortOrder -> ShowS
$cshow :: SortOrder -> String
show :: SortOrder -> String
$cshowList :: [SortOrder] -> ShowS
showList :: [SortOrder] -> ShowS
Show, SortOrder -> SortOrder -> Bool
(SortOrder -> SortOrder -> Bool)
-> (SortOrder -> SortOrder -> Bool) -> Eq SortOrder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SortOrder -> SortOrder -> Bool
== :: SortOrder -> SortOrder -> Bool
$c/= :: SortOrder -> SortOrder -> Bool
/= :: SortOrder -> SortOrder -> Bool
Eq)
sortStore
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> SortOpts
-> m (f Integer)
sortStore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> SortOpts -> m (f Integer)
sortStore ByteString
key ByteString
dest = ByteString -> Maybe ByteString -> SortOpts -> m (f Integer)
forall a (m :: * -> *) (f :: * -> *).
(RedisResult a, RedisCtx m f) =>
ByteString -> Maybe ByteString -> SortOpts -> m (f a)
sortInternal ByteString
key (ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
dest)
sort
:: (RedisCtx m f)
=> ByteString
-> SortOpts
-> m (f [ByteString])
sort :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> SortOpts -> m (f [ByteString])
sort ByteString
key = ByteString -> Maybe ByteString -> SortOpts -> m (f [ByteString])
forall a (m :: * -> *) (f :: * -> *).
(RedisResult a, RedisCtx m f) =>
ByteString -> Maybe ByteString -> SortOpts -> m (f a)
sortInternal ByteString
key Maybe ByteString
forall a. Maybe a
Nothing
sortInternal
:: (RedisResult a, RedisCtx m f)
=> ByteString
-> Maybe ByteString
-> SortOpts
-> m (f a)
sortInternal :: forall a (m :: * -> *) (f :: * -> *).
(RedisResult a, RedisCtx m f) =>
ByteString -> Maybe ByteString -> SortOpts -> m (f a)
sortInternal ByteString
key Maybe ByteString
destination SortOpts{Bool
[ByteString]
Maybe ByteString
(Integer, Integer)
SortOrder
sortBy :: SortOpts -> Maybe ByteString
sortLimit :: SortOpts -> (Integer, Integer)
sortGet :: SortOpts -> [ByteString]
sortOrder :: SortOpts -> SortOrder
sortAlpha :: SortOpts -> Bool
sortBy :: Maybe ByteString
sortLimit :: (Integer, Integer)
sortGet :: [ByteString]
sortOrder :: SortOrder
sortAlpha :: Bool
..} = [ByteString] -> m (f a)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f a)) -> [ByteString] -> m (f a)
forall a b. (a -> b) -> a -> b
$
[[ByteString]] -> [ByteString]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[ByteString
"SORT", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key], [ByteString]
by, [ByteString]
limit, [ByteString]
get, [ByteString]
order, [ByteString]
alpha, [ByteString]
store]
where
by :: [ByteString]
by = [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ByteString
pattern -> [ByteString
"BY", ByteString
pattern]) Maybe ByteString
sortBy
limit :: [ByteString]
limit = let (Integer
off,Integer
cnt) = (Integer, Integer)
sortLimit in [ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
off, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
cnt]
get :: [ByteString]
get = (ByteString -> [ByteString]) -> [ByteString] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\ByteString
pattern -> [ByteString
"GET", ByteString
pattern]) [ByteString]
sortGet
order :: [ByteString]
order = case SortOrder
sortOrder of SortOrder
Desc -> [ByteString
"DESC"]; SortOrder
Asc -> [ByteString
"ASC"]
alpha :: [ByteString]
alpha = [ByteString
"ALPHA" | Bool
sortAlpha]
store :: [ByteString]
store = [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ByteString
dest -> [ByteString
"STORE", ByteString
dest]) Maybe ByteString
destination
data Aggregate = Sum | Min | Max deriving (Int -> Aggregate -> ShowS
[Aggregate] -> ShowS
Aggregate -> String
(Int -> Aggregate -> ShowS)
-> (Aggregate -> String)
-> ([Aggregate] -> ShowS)
-> Show Aggregate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Aggregate -> ShowS
showsPrec :: Int -> Aggregate -> ShowS
$cshow :: Aggregate -> String
show :: Aggregate -> String
$cshowList :: [Aggregate] -> ShowS
showList :: [Aggregate] -> ShowS
Show,Aggregate -> Aggregate -> Bool
(Aggregate -> Aggregate -> Bool)
-> (Aggregate -> Aggregate -> Bool) -> Eq Aggregate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Aggregate -> Aggregate -> Bool
== :: Aggregate -> Aggregate -> Bool
$c/= :: Aggregate -> Aggregate -> Bool
/= :: Aggregate -> Aggregate -> Bool
Eq)
zunionstore
:: (RedisCtx m f)
=> ByteString
-> [ByteString]
-> Aggregate
-> m (f Integer)
zunionstore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> Aggregate -> m (f Integer)
zunionstore ByteString
dest [ByteString]
keys =
ByteString
-> ByteString
-> [ByteString]
-> [Double]
-> Aggregate
-> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> [ByteString]
-> [Double]
-> Aggregate
-> m (f Integer)
zstoreInternal ByteString
"ZUNIONSTORE" ByteString
dest [ByteString]
keys []
zunionstoreWeights
:: (RedisCtx m f)
=> ByteString
-> [(ByteString,Double)]
-> Aggregate
-> m (f Integer)
zunionstoreWeights :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [(ByteString, Double)] -> Aggregate -> m (f Integer)
zunionstoreWeights ByteString
dest [(ByteString, Double)]
kws =
let ([ByteString]
keys,[Double]
weights) = [(ByteString, Double)] -> ([ByteString], [Double])
forall a b. [(a, b)] -> ([a], [b])
unzip [(ByteString, Double)]
kws
in ByteString
-> ByteString
-> [ByteString]
-> [Double]
-> Aggregate
-> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> [ByteString]
-> [Double]
-> Aggregate
-> m (f Integer)
zstoreInternal ByteString
"ZUNIONSTORE" ByteString
dest [ByteString]
keys [Double]
weights
zinterstore
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> Aggregate
-> m (f Integer)
zinterstore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> Aggregate -> m (f Integer)
zinterstore ByteString
dest (ByteString
key_:|[ByteString]
keys_) =
ByteString
-> ByteString
-> [ByteString]
-> [Double]
-> Aggregate
-> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> [ByteString]
-> [Double]
-> Aggregate
-> m (f Integer)
zstoreInternal ByteString
"ZINTERSTORE" ByteString
dest (ByteString
key_ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
keys_) []
zinterstoreWeights
:: (RedisCtx m f)
=> ByteString
-> NonEmpty (ByteString,Double)
-> Aggregate
-> m (f Integer)
zinterstoreWeights :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty (ByteString, Double) -> Aggregate -> m (f Integer)
zinterstoreWeights ByteString
dest NonEmpty (ByteString, Double)
kws =
let ([ByteString]
keys,[Double]
weights) = [(ByteString, Double)] -> ([ByteString], [Double])
forall a b. [(a, b)] -> ([a], [b])
unzip (NonEmpty (ByteString, Double) -> [(ByteString, Double)]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty (ByteString, Double)
kws)
in ByteString
-> ByteString
-> [ByteString]
-> [Double]
-> Aggregate
-> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> [ByteString]
-> [Double]
-> Aggregate
-> m (f Integer)
zstoreInternal ByteString
"ZINTERSTORE" ByteString
dest [ByteString]
keys [Double]
weights
zstoreInternal
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> [ByteString]
-> [Double]
-> Aggregate
-> m (f Integer)
zstoreInternal :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> [ByteString]
-> [Double]
-> Aggregate
-> m (f Integer)
zstoreInternal ByteString
cmd ByteString
dest [ByteString]
keys [Double]
weights Aggregate
aggregate = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$
[[ByteString]] -> [ByteString]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [ [ByteString
cmd, ByteString
dest, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Integer -> ByteString) -> (Int -> Integer) -> Int -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> ByteString) -> Int -> ByteString
forall a b. (a -> b) -> a -> b
$ [ByteString] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ByteString]
keys ], [ByteString]
keys
, if [Double] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Double]
weights then [] else ByteString
"WEIGHTS" ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: (Double -> ByteString) -> [Double] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode [Double]
weights
, [ByteString
"AGGREGATE", ByteString
aggregate']
]
where
aggregate' :: ByteString
aggregate' = case Aggregate
aggregate of
Aggregate
Sum -> ByteString
"SUM"
Aggregate
Min -> ByteString
"MIN"
Aggregate
Max -> ByteString
"MAX"
zdiff
:: (RedisCtx m f)
=> NonEmpty ByteString
-> m (f [ByteString])
zdiff :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [ByteString])
zdiff NonEmpty ByteString
keys = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [ByteString]))
-> [ByteString] -> m (f [ByteString])
forall a b. (a -> b) -> a -> b
$ ByteString -> NonEmpty ByteString -> [ByteString]
zAggregateKeysArgs ByteString
"ZDIFF" NonEmpty ByteString
keys
zdiffWithscores
:: (RedisCtx m f)
=> NonEmpty ByteString
-> m (f [(ByteString, Double)])
zdiffWithscores :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [(ByteString, Double)])
zdiffWithscores NonEmpty ByteString
keys = [ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [(ByteString, Double)]))
-> [ByteString] -> m (f [(ByteString, Double)])
forall a b. (a -> b) -> a -> b
$ ByteString -> NonEmpty ByteString -> [ByteString]
zAggregateKeysArgs ByteString
"ZDIFF" NonEmpty ByteString
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"WITHSCORES"]
zdiffstore
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f Integer)
zdiffstore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
zdiffstore ByteString
destination NonEmpty ByteString
keys =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"ZDIFFSTORE", ByteString
destination] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString] -> [ByteString]
forall a. HasCallStack => [a] -> [a]
tail (ByteString -> NonEmpty ByteString -> [ByteString]
zAggregateKeysArgs ByteString
"ZDIFF" NonEmpty ByteString
keys)
zinter
:: (RedisCtx m f)
=> NonEmpty ByteString
-> m (f [ByteString])
zinter :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [ByteString])
zinter NonEmpty ByteString
keys = NonEmpty ByteString -> ZAggregateOpts -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> ZAggregateOpts -> m (f [ByteString])
zinterOpts NonEmpty ByteString
keys ZAggregateOpts
defaultZAggregateOpts
data ZAggregateOpts = ZAggregateOpts
{ ZAggregateOpts -> [Double]
zAggregateWeights :: [Double]
, ZAggregateOpts -> Aggregate
zAggregateAggregate :: Aggregate
} deriving (Int -> ZAggregateOpts -> ShowS
[ZAggregateOpts] -> ShowS
ZAggregateOpts -> String
(Int -> ZAggregateOpts -> ShowS)
-> (ZAggregateOpts -> String)
-> ([ZAggregateOpts] -> ShowS)
-> Show ZAggregateOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ZAggregateOpts -> ShowS
showsPrec :: Int -> ZAggregateOpts -> ShowS
$cshow :: ZAggregateOpts -> String
show :: ZAggregateOpts -> String
$cshowList :: [ZAggregateOpts] -> ShowS
showList :: [ZAggregateOpts] -> ShowS
Show, ZAggregateOpts -> ZAggregateOpts -> Bool
(ZAggregateOpts -> ZAggregateOpts -> Bool)
-> (ZAggregateOpts -> ZAggregateOpts -> Bool) -> Eq ZAggregateOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ZAggregateOpts -> ZAggregateOpts -> Bool
== :: ZAggregateOpts -> ZAggregateOpts -> Bool
$c/= :: ZAggregateOpts -> ZAggregateOpts -> Bool
/= :: ZAggregateOpts -> ZAggregateOpts -> Bool
Eq)
defaultZAggregateOpts :: ZAggregateOpts
defaultZAggregateOpts :: ZAggregateOpts
defaultZAggregateOpts = ZAggregateOpts
{ zAggregateWeights :: [Double]
zAggregateWeights = []
, zAggregateAggregate :: Aggregate
zAggregateAggregate = Aggregate
Sum
}
zinterWithscores
:: (RedisCtx m f)
=> NonEmpty ByteString
-> m (f [(ByteString, Double)])
zinterWithscores :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [(ByteString, Double)])
zinterWithscores NonEmpty ByteString
keys = NonEmpty ByteString
-> ZAggregateOpts -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> ZAggregateOpts -> m (f [(ByteString, Double)])
zinterWithscoresOpts NonEmpty ByteString
keys ZAggregateOpts
defaultZAggregateOpts
zinterOpts
:: (RedisCtx m f)
=> NonEmpty ByteString
-> ZAggregateOpts
-> m (f [ByteString])
zinterOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> ZAggregateOpts -> m (f [ByteString])
zinterOpts NonEmpty ByteString
keys ZAggregateOpts
opts = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [ByteString]))
-> [ByteString] -> m (f [ByteString])
forall a b. (a -> b) -> a -> b
$ ByteString
-> NonEmpty ByteString -> ZAggregateOpts -> Bool -> [ByteString]
zAggregateInternalArgs ByteString
"ZINTER" NonEmpty ByteString
keys ZAggregateOpts
opts Bool
False
zinterWithscoresOpts
:: (RedisCtx m f)
=> NonEmpty ByteString
-> ZAggregateOpts
-> m (f [(ByteString, Double)])
zinterWithscoresOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> ZAggregateOpts -> m (f [(ByteString, Double)])
zinterWithscoresOpts NonEmpty ByteString
keys ZAggregateOpts
opts = [ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [(ByteString, Double)]))
-> [ByteString] -> m (f [(ByteString, Double)])
forall a b. (a -> b) -> a -> b
$ ByteString
-> NonEmpty ByteString -> ZAggregateOpts -> Bool -> [ByteString]
zAggregateInternalArgs ByteString
"ZINTER" NonEmpty ByteString
keys ZAggregateOpts
opts Bool
True
zunion
:: (RedisCtx m f)
=> NonEmpty ByteString
-> m (f [ByteString])
zunion :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [ByteString])
zunion NonEmpty ByteString
keys = NonEmpty ByteString -> ZAggregateOpts -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> ZAggregateOpts -> m (f [ByteString])
zunionOpts NonEmpty ByteString
keys ZAggregateOpts
defaultZAggregateOpts
zunionWithscores
:: (RedisCtx m f)
=> NonEmpty ByteString
-> m (f [(ByteString, Double)])
zunionWithscores :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f [(ByteString, Double)])
zunionWithscores NonEmpty ByteString
keys = NonEmpty ByteString
-> ZAggregateOpts -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> ZAggregateOpts -> m (f [(ByteString, Double)])
zunionWithscoresOpts NonEmpty ByteString
keys ZAggregateOpts
defaultZAggregateOpts
zunionOpts
:: (RedisCtx m f)
=> NonEmpty ByteString
-> ZAggregateOpts
-> m (f [ByteString])
zunionOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> ZAggregateOpts -> m (f [ByteString])
zunionOpts NonEmpty ByteString
keys ZAggregateOpts
opts = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [ByteString]))
-> [ByteString] -> m (f [ByteString])
forall a b. (a -> b) -> a -> b
$ ByteString
-> NonEmpty ByteString -> ZAggregateOpts -> Bool -> [ByteString]
zAggregateInternalArgs ByteString
"ZUNION" NonEmpty ByteString
keys ZAggregateOpts
opts Bool
False
zunionWithscoresOpts
:: (RedisCtx m f)
=> NonEmpty ByteString
-> ZAggregateOpts
-> m (f [(ByteString, Double)])
zunionWithscoresOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> ZAggregateOpts -> m (f [(ByteString, Double)])
zunionWithscoresOpts NonEmpty ByteString
keys ZAggregateOpts
opts = [ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [(ByteString, Double)]))
-> [ByteString] -> m (f [(ByteString, Double)])
forall a b. (a -> b) -> a -> b
$ ByteString
-> NonEmpty ByteString -> ZAggregateOpts -> Bool -> [ByteString]
zAggregateInternalArgs ByteString
"ZUNION" NonEmpty ByteString
keys ZAggregateOpts
opts Bool
True
zAggregateKeysArgs :: ByteString -> NonEmpty ByteString -> [ByteString]
zAggregateKeysArgs :: ByteString -> NonEmpty ByteString -> [ByteString]
zAggregateKeysArgs ByteString
cmd NonEmpty ByteString
keys =
[ByteString
cmd, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Integer -> ByteString) -> (Int -> Integer) -> Int -> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> ByteString) -> Int -> ByteString
forall a b. (a -> b) -> a -> b
$ NonEmpty ByteString -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty ByteString
keys] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
keys
zAggregateInternalArgs :: ByteString -> NonEmpty ByteString -> ZAggregateOpts -> Bool -> [ByteString]
zAggregateInternalArgs :: ByteString
-> NonEmpty ByteString -> ZAggregateOpts -> Bool -> [ByteString]
zAggregateInternalArgs ByteString
cmd NonEmpty ByteString
keys ZAggregateOpts{[Double]
Aggregate
zAggregateWeights :: ZAggregateOpts -> [Double]
zAggregateAggregate :: ZAggregateOpts -> Aggregate
zAggregateWeights :: [Double]
zAggregateAggregate :: Aggregate
..} Bool
withScores =
ByteString -> NonEmpty ByteString -> [ByteString]
zAggregateKeysArgs ByteString
cmd NonEmpty ByteString
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
weightsArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
aggregateArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
withScoresArg
where
weightsArg :: [ByteString]
weightsArg = [ByteString
"WEIGHTS" | Bool -> Bool
not ([Double] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Double]
zAggregateWeights)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (Double -> ByteString) -> [Double] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode [Double]
zAggregateWeights
aggregateArg :: [ByteString]
aggregateArg = [ByteString
"AGGREGATE", Aggregate -> ByteString
forall {a}. IsString a => Aggregate -> a
aggregateValue Aggregate
zAggregateAggregate]
withScoresArg :: [ByteString]
withScoresArg = [ByteString
"WITHSCORES" | Bool
withScores]
aggregateValue :: Aggregate -> a
aggregateValue Aggregate
Sum = a
"SUM"
aggregateValue Aggregate
Min = a
"MIN"
aggregateValue Aggregate
Max = a
"MAX"
eval
:: (RedisCtx m f, RedisResult a)
=> ByteString
-> [ByteString]
-> [ByteString]
-> m (f a)
eval :: forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
ByteString -> [ByteString] -> [ByteString] -> m (f a)
eval ByteString
script [ByteString]
keys [ByteString]
args =
[ByteString] -> m (f a)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f a)) -> [ByteString] -> m (f a)
forall a b. (a -> b) -> a -> b
$ [ByteString
"EVAL", ByteString
script, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
numkeys] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
args
where
numkeys :: Integer
numkeys = Int -> Integer
forall a. Integral a => a -> Integer
toInteger ([ByteString] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ByteString]
keys)
evalsha
:: (RedisCtx m f, RedisResult a)
=> ByteString
-> [ByteString]
-> [ByteString]
-> m (f a)
evalsha :: forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
ByteString -> [ByteString] -> [ByteString] -> m (f a)
evalsha ByteString
script [ByteString]
keys [ByteString]
args =
[ByteString] -> m (f a)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f a)) -> [ByteString] -> m (f a)
forall a b. (a -> b) -> a -> b
$ [ByteString
"EVALSHA", ByteString
script, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
numkeys] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
args
where
numkeys :: Integer
numkeys = Int -> Integer
forall a. Integral a => a -> Integer
toInteger ([ByteString] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ByteString]
keys)
fcall
:: (RedisCtx m f, RedisResult a)
=> ByteString
-> [ByteString]
-> [ByteString]
-> m (f a)
fcall :: forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
ByteString -> [ByteString] -> [ByteString] -> m (f a)
fcall ByteString
functionName [ByteString]
keys [ByteString]
args =
[ByteString] -> m (f a)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f a)) -> [ByteString] -> m (f a)
forall a b. (a -> b) -> a -> b
$ [ByteString
"FCALL", ByteString
functionName, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
numkeys] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
args
where
numkeys :: Integer
numkeys = Int -> Integer
forall a. Integral a => a -> Integer
toInteger ([ByteString] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ByteString]
keys)
fcallReadonly
:: (RedisCtx m f, RedisResult a)
=> ByteString
-> [ByteString]
-> [ByteString]
-> m (f a)
fcallReadonly :: forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
ByteString -> [ByteString] -> [ByteString] -> m (f a)
fcallReadonly ByteString
functionName [ByteString]
keys [ByteString]
args =
[ByteString] -> m (f a)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f a)) -> [ByteString] -> m (f a)
forall a b. (a -> b) -> a -> b
$ [ByteString
"FCALL_RO", ByteString
functionName, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
numkeys] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
args
where
numkeys :: Integer
numkeys = Int -> Integer
forall a. Integral a => a -> Integer
toInteger ([ByteString] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [ByteString]
keys)
data FunctionListOpts = FunctionListOpts
{ FunctionListOpts -> Maybe ByteString
functionListLibraryName :: Maybe ByteString
, FunctionListOpts -> Bool
functionListWithCode :: Bool
} deriving (Int -> FunctionListOpts -> ShowS
[FunctionListOpts] -> ShowS
FunctionListOpts -> String
(Int -> FunctionListOpts -> ShowS)
-> (FunctionListOpts -> String)
-> ([FunctionListOpts] -> ShowS)
-> Show FunctionListOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FunctionListOpts -> ShowS
showsPrec :: Int -> FunctionListOpts -> ShowS
$cshow :: FunctionListOpts -> String
show :: FunctionListOpts -> String
$cshowList :: [FunctionListOpts] -> ShowS
showList :: [FunctionListOpts] -> ShowS
Show, FunctionListOpts -> FunctionListOpts -> Bool
(FunctionListOpts -> FunctionListOpts -> Bool)
-> (FunctionListOpts -> FunctionListOpts -> Bool)
-> Eq FunctionListOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FunctionListOpts -> FunctionListOpts -> Bool
== :: FunctionListOpts -> FunctionListOpts -> Bool
$c/= :: FunctionListOpts -> FunctionListOpts -> Bool
/= :: FunctionListOpts -> FunctionListOpts -> Bool
Eq)
defaultFunctionListOpts :: FunctionListOpts
defaultFunctionListOpts :: FunctionListOpts
defaultFunctionListOpts = FunctionListOpts
{ functionListLibraryName :: Maybe ByteString
functionListLibraryName = Maybe ByteString
forall a. Maybe a
Nothing
, functionListWithCode :: Bool
functionListWithCode = Bool
False
}
data FunctionRestorePolicy
= FunctionRestoreAppend
| FunctionRestoreFlush
| FunctionRestoreReplace
deriving (Int -> FunctionRestorePolicy -> ShowS
[FunctionRestorePolicy] -> ShowS
FunctionRestorePolicy -> String
(Int -> FunctionRestorePolicy -> ShowS)
-> (FunctionRestorePolicy -> String)
-> ([FunctionRestorePolicy] -> ShowS)
-> Show FunctionRestorePolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> FunctionRestorePolicy -> ShowS
showsPrec :: Int -> FunctionRestorePolicy -> ShowS
$cshow :: FunctionRestorePolicy -> String
show :: FunctionRestorePolicy -> String
$cshowList :: [FunctionRestorePolicy] -> ShowS
showList :: [FunctionRestorePolicy] -> ShowS
Show, FunctionRestorePolicy -> FunctionRestorePolicy -> Bool
(FunctionRestorePolicy -> FunctionRestorePolicy -> Bool)
-> (FunctionRestorePolicy -> FunctionRestorePolicy -> Bool)
-> Eq FunctionRestorePolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: FunctionRestorePolicy -> FunctionRestorePolicy -> Bool
== :: FunctionRestorePolicy -> FunctionRestorePolicy -> Bool
$c/= :: FunctionRestorePolicy -> FunctionRestorePolicy -> Bool
/= :: FunctionRestorePolicy -> FunctionRestorePolicy -> Bool
Eq)
instance RedisArg FunctionRestorePolicy where
encode :: FunctionRestorePolicy -> ByteString
encode FunctionRestorePolicy
FunctionRestoreAppend = ByteString
"APPEND"
encode FunctionRestorePolicy
FunctionRestoreFlush = ByteString
"FLUSH"
encode FunctionRestorePolicy
FunctionRestoreReplace = ByteString
"REPLACE"
functionDelete
:: (RedisCtx m f)
=> ByteString
-> m (f Status)
functionDelete :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Status)
functionDelete ByteString
libraryName = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FUNCTION", ByteString
"DELETE", ByteString
libraryName]
functionDump
:: (RedisCtx m f)
=> m (f ByteString)
functionDump :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f ByteString)
functionDump = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FUNCTION", ByteString
"DUMP"]
functionFlush
:: (RedisCtx m f)
=> m (f Status)
functionFlush :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
functionFlush = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FUNCTION", ByteString
"FLUSH"]
functionFlushOpts
:: (RedisCtx m f)
=> FlushOpts
-> m (f Status)
functionFlushOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
FlushOpts -> m (f Status)
functionFlushOpts FlushOpts
opts = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FUNCTION", ByteString
"FLUSH", FlushOpts -> ByteString
forall a. RedisArg a => a -> ByteString
encode FlushOpts
opts]
functionHelp
:: (RedisCtx m f)
=> m (f [ByteString])
functionHelp :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f [ByteString])
functionHelp = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FUNCTION", ByteString
"HELP"]
functionKill
:: (RedisCtx m f)
=> m (f Status)
functionKill :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
functionKill = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FUNCTION", ByteString
"KILL"]
functionList
:: (RedisCtx m f)
=> m (f Reply)
functionList :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Reply)
functionList = FunctionListOpts -> m (f Reply)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
FunctionListOpts -> m (f Reply)
functionListOpts FunctionListOpts
defaultFunctionListOpts
functionListOpts
:: (RedisCtx m f)
=> FunctionListOpts
-> m (f Reply)
functionListOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
FunctionListOpts -> m (f Reply)
functionListOpts FunctionListOpts{Bool
Maybe ByteString
functionListLibraryName :: FunctionListOpts -> Maybe ByteString
functionListWithCode :: FunctionListOpts -> Bool
functionListLibraryName :: Maybe ByteString
functionListWithCode :: Bool
..} =
[ByteString] -> m (f Reply)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Reply)) -> [ByteString] -> m (f Reply)
forall a b. (a -> b) -> a -> b
$ [ByteString
"FUNCTION", ByteString
"LIST"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
libraryArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
withCodeArg
where
libraryArg :: [ByteString]
libraryArg = [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ByteString
libraryName -> [ByteString
"LIBRARYNAME", ByteString
libraryName]) Maybe ByteString
functionListLibraryName
withCodeArg :: [ByteString]
withCodeArg = [ByteString
"WITHCODE" | Bool
functionListWithCode]
functionLoad
:: (RedisCtx m f)
=> ByteString
-> m (f ByteString)
functionLoad :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ByteString)
functionLoad ByteString
libraryCode = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FUNCTION", ByteString
"LOAD", ByteString
libraryCode]
functionLoadReplace
:: (RedisCtx m f)
=> ByteString
-> m (f ByteString)
functionLoadReplace :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ByteString)
functionLoadReplace ByteString
libraryCode = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FUNCTION", ByteString
"LOAD", ByteString
"REPLACE", ByteString
libraryCode]
functionRestore
:: (RedisCtx m f)
=> ByteString
-> Maybe FunctionRestorePolicy
-> m (f Status)
functionRestore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Maybe FunctionRestorePolicy -> m (f Status)
functionRestore ByteString
payload Maybe FunctionRestorePolicy
restorePolicy =
[ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$ [ByteString
"FUNCTION", ByteString
"RESTORE", ByteString
payload] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (FunctionRestorePolicy -> [ByteString])
-> Maybe FunctionRestorePolicy
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\FunctionRestorePolicy
policy -> [FunctionRestorePolicy -> ByteString
forall a. RedisArg a => a -> ByteString
encode FunctionRestorePolicy
policy]) Maybe FunctionRestorePolicy
restorePolicy
functionStats
:: (RedisCtx m f)
=> m (f Reply)
functionStats :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Reply)
functionStats = [ByteString] -> m (f Reply)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FUNCTION", ByteString
"STATS"]
bitcount
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
bitcount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
bitcount ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"BITCOUNT", ByteString
key]
bitcountRange
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> m (f Integer)
bitcountRange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f Integer)
bitcountRange ByteString
key Integer
start Integer
end =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"BITCOUNT", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
end]
bitopAnd
:: (RedisCtx m f)
=> ByteString
-> [ByteString]
-> m (f Integer)
bitopAnd :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> m (f Integer)
bitopAnd ByteString
dst [ByteString]
srcs = ByteString -> [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> m (f Integer)
bitop ByteString
"AND" (ByteString
dstByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
srcs)
bitopOr
:: (RedisCtx m f)
=> ByteString
-> [ByteString]
-> m (f Integer)
bitopOr :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> m (f Integer)
bitopOr ByteString
dst [ByteString]
srcs = ByteString -> [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> m (f Integer)
bitop ByteString
"OR" (ByteString
dstByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
srcs)
bitopXor
:: (RedisCtx m f)
=> ByteString
-> [ByteString]
-> m (f Integer)
bitopXor :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> m (f Integer)
bitopXor ByteString
dst [ByteString]
srcs = ByteString -> [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> m (f Integer)
bitop ByteString
"XOR" (ByteString
dstByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
srcs)
bitopNot
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f Integer)
bitopNot :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Integer)
bitopNot ByteString
dst ByteString
src = ByteString -> [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> m (f Integer)
bitop ByteString
"NOT" [ByteString
dst, ByteString
src]
bitop
:: (RedisCtx m f)
=> ByteString
-> [ByteString]
-> m (f Integer)
bitop :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> m (f Integer)
bitop ByteString
op [ByteString]
ks = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ ByteString
"BITOP" ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
op ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
ks
data VAddQuantization
= VAddNoQuant
| VAddQ8
| VAddBin
deriving (Int -> VAddQuantization -> ShowS
[VAddQuantization] -> ShowS
VAddQuantization -> String
(Int -> VAddQuantization -> ShowS)
-> (VAddQuantization -> String)
-> ([VAddQuantization] -> ShowS)
-> Show VAddQuantization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VAddQuantization -> ShowS
showsPrec :: Int -> VAddQuantization -> ShowS
$cshow :: VAddQuantization -> String
show :: VAddQuantization -> String
$cshowList :: [VAddQuantization] -> ShowS
showList :: [VAddQuantization] -> ShowS
Show, VAddQuantization -> VAddQuantization -> Bool
(VAddQuantization -> VAddQuantization -> Bool)
-> (VAddQuantization -> VAddQuantization -> Bool)
-> Eq VAddQuantization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VAddQuantization -> VAddQuantization -> Bool
== :: VAddQuantization -> VAddQuantization -> Bool
$c/= :: VAddQuantization -> VAddQuantization -> Bool
/= :: VAddQuantization -> VAddQuantization -> Bool
Eq)
instance RedisArg VAddQuantization where
encode :: VAddQuantization -> ByteString
encode VAddQuantization
VAddNoQuant = ByteString
"NOQUANT"
encode VAddQuantization
VAddQ8 = ByteString
"Q8"
encode VAddQuantization
VAddBin = ByteString
"BIN"
data VAddOpts = VAddOpts
{ VAddOpts -> Maybe Integer
vAddReduceDim :: Maybe Integer
, VAddOpts -> Bool
vAddCas :: Bool
, VAddOpts -> Maybe VAddQuantization
vAddQuantization :: Maybe VAddQuantization
, VAddOpts -> Maybe Integer
vAddBuildExplorationFactor :: Maybe Integer
, VAddOpts -> Maybe ByteString
vAddAttributes :: Maybe ByteString
, VAddOpts -> Maybe Integer
vAddNumLinks :: Maybe Integer
} deriving (Int -> VAddOpts -> ShowS
[VAddOpts] -> ShowS
VAddOpts -> String
(Int -> VAddOpts -> ShowS)
-> (VAddOpts -> String) -> ([VAddOpts] -> ShowS) -> Show VAddOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VAddOpts -> ShowS
showsPrec :: Int -> VAddOpts -> ShowS
$cshow :: VAddOpts -> String
show :: VAddOpts -> String
$cshowList :: [VAddOpts] -> ShowS
showList :: [VAddOpts] -> ShowS
Show, VAddOpts -> VAddOpts -> Bool
(VAddOpts -> VAddOpts -> Bool)
-> (VAddOpts -> VAddOpts -> Bool) -> Eq VAddOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VAddOpts -> VAddOpts -> Bool
== :: VAddOpts -> VAddOpts -> Bool
$c/= :: VAddOpts -> VAddOpts -> Bool
/= :: VAddOpts -> VAddOpts -> Bool
Eq)
data VQuantization
= VQuantizationFP32
| VQuantizationBin
| VQuantizationQ8
deriving (Int -> VQuantization -> ShowS
[VQuantization] -> ShowS
VQuantization -> String
(Int -> VQuantization -> ShowS)
-> (VQuantization -> String)
-> ([VQuantization] -> ShowS)
-> Show VQuantization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VQuantization -> ShowS
showsPrec :: Int -> VQuantization -> ShowS
$cshow :: VQuantization -> String
show :: VQuantization -> String
$cshowList :: [VQuantization] -> ShowS
showList :: [VQuantization] -> ShowS
Show, VQuantization -> VQuantization -> Bool
(VQuantization -> VQuantization -> Bool)
-> (VQuantization -> VQuantization -> Bool) -> Eq VQuantization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VQuantization -> VQuantization -> Bool
== :: VQuantization -> VQuantization -> Bool
$c/= :: VQuantization -> VQuantization -> Bool
/= :: VQuantization -> VQuantization -> Bool
Eq)
instance RedisArg VQuantization where
encode :: VQuantization -> ByteString
encode VQuantization
VQuantizationFP32 = ByteString
"FP32"
encode VQuantization
VQuantizationBin = ByteString
"BIN"
encode VQuantization
VQuantizationQ8 = ByteString
"Q8"
instance RedisResult VQuantization where
decode :: Reply -> Either Reply VQuantization
decode (SingleLine ByteString
"fp32") = VQuantization -> Either Reply VQuantization
forall a b. b -> Either a b
Right VQuantization
VQuantizationFP32
decode (SingleLine ByteString
"f32") = VQuantization -> Either Reply VQuantization
forall a b. b -> Either a b
Right VQuantization
VQuantizationFP32
decode (SingleLine ByteString
"bin") = VQuantization -> Either Reply VQuantization
forall a b. b -> Either a b
Right VQuantization
VQuantizationBin
decode (SingleLine ByteString
"q8") = VQuantization -> Either Reply VQuantization
forall a b. b -> Either a b
Right VQuantization
VQuantizationQ8
decode (SingleLine ByteString
"int8") = VQuantization -> Either Reply VQuantization
forall a b. b -> Either a b
Right VQuantization
VQuantizationQ8
decode (Bulk (Just ByteString
"fp32")) = VQuantization -> Either Reply VQuantization
forall a b. b -> Either a b
Right VQuantization
VQuantizationFP32
decode (Bulk (Just ByteString
"f32")) = VQuantization -> Either Reply VQuantization
forall a b. b -> Either a b
Right VQuantization
VQuantizationFP32
decode (Bulk (Just ByteString
"bin")) = VQuantization -> Either Reply VQuantization
forall a b. b -> Either a b
Right VQuantization
VQuantizationBin
decode (Bulk (Just ByteString
"q8")) = VQuantization -> Either Reply VQuantization
forall a b. b -> Either a b
Right VQuantization
VQuantizationQ8
decode (Bulk (Just ByteString
"int8")) = VQuantization -> Either Reply VQuantization
forall a b. b -> Either a b
Right VQuantization
VQuantizationQ8
decode Reply
r = Reply -> Either Reply VQuantization
forall a b. a -> Either a b
Left Reply
r
data VEmbRawResponse = VEmbRawResponse
{ VEmbRawResponse -> VQuantization
vEmbRawQuantization :: VQuantization
, VEmbRawResponse -> ByteString
vEmbRawData :: ByteString
, VEmbRawResponse -> Double
vEmbRawNorm :: Double
, VEmbRawResponse -> Maybe Double
vEmbRawRange :: Maybe Double
} deriving (Int -> VEmbRawResponse -> ShowS
[VEmbRawResponse] -> ShowS
VEmbRawResponse -> String
(Int -> VEmbRawResponse -> ShowS)
-> (VEmbRawResponse -> String)
-> ([VEmbRawResponse] -> ShowS)
-> Show VEmbRawResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VEmbRawResponse -> ShowS
showsPrec :: Int -> VEmbRawResponse -> ShowS
$cshow :: VEmbRawResponse -> String
show :: VEmbRawResponse -> String
$cshowList :: [VEmbRawResponse] -> ShowS
showList :: [VEmbRawResponse] -> ShowS
Show, VEmbRawResponse -> VEmbRawResponse -> Bool
(VEmbRawResponse -> VEmbRawResponse -> Bool)
-> (VEmbRawResponse -> VEmbRawResponse -> Bool)
-> Eq VEmbRawResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VEmbRawResponse -> VEmbRawResponse -> Bool
== :: VEmbRawResponse -> VEmbRawResponse -> Bool
$c/= :: VEmbRawResponse -> VEmbRawResponse -> Bool
/= :: VEmbRawResponse -> VEmbRawResponse -> Bool
Eq)
instance RedisResult VEmbRawResponse where
decode :: Reply -> Either Reply VEmbRawResponse
decode (MultiBulk (Just [Reply
quantizationReply, Reply
rawDataReply, Reply
normReply])) =
VQuantization
-> ByteString -> Double -> Maybe Double -> VEmbRawResponse
VEmbRawResponse
(VQuantization
-> ByteString -> Double -> Maybe Double -> VEmbRawResponse)
-> Either Reply VQuantization
-> Either
Reply (ByteString -> Double -> Maybe Double -> VEmbRawResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply VQuantization
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
quantizationReply
Either
Reply (ByteString -> Double -> Maybe Double -> VEmbRawResponse)
-> Either Reply ByteString
-> Either Reply (Double -> Maybe Double -> VEmbRawResponse)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
rawDataReply
Either Reply (Double -> Maybe Double -> VEmbRawResponse)
-> Either Reply Double
-> Either Reply (Maybe Double -> VEmbRawResponse)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Double
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
normReply
Either Reply (Maybe Double -> VEmbRawResponse)
-> Either Reply (Maybe Double) -> Either Reply VEmbRawResponse
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Double -> Either Reply (Maybe Double)
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Double
forall a. Maybe a
Nothing
decode (MultiBulk (Just [Reply
quantizationReply, Reply
rawDataReply, Reply
normReply, Reply
rangeReply])) =
VQuantization
-> ByteString -> Double -> Maybe Double -> VEmbRawResponse
VEmbRawResponse
(VQuantization
-> ByteString -> Double -> Maybe Double -> VEmbRawResponse)
-> Either Reply VQuantization
-> Either
Reply (ByteString -> Double -> Maybe Double -> VEmbRawResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply VQuantization
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
quantizationReply
Either
Reply (ByteString -> Double -> Maybe Double -> VEmbRawResponse)
-> Either Reply ByteString
-> Either Reply (Double -> Maybe Double -> VEmbRawResponse)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
rawDataReply
Either Reply (Double -> Maybe Double -> VEmbRawResponse)
-> Either Reply Double
-> Either Reply (Maybe Double -> VEmbRawResponse)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Double
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
normReply
Either Reply (Maybe Double -> VEmbRawResponse)
-> Either Reply (Maybe Double) -> Either Reply VEmbRawResponse
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Double -> Maybe Double
forall a. a -> Maybe a
Just (Double -> Maybe Double)
-> Either Reply Double -> Either Reply (Maybe Double)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply Double
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
rangeReply)
decode Reply
r = Reply -> Either Reply VEmbRawResponse
forall a b. a -> Either a b
Left Reply
r
data VInfoResponse = VInfoResponse
{ VInfoResponse -> Maybe ByteString
vInfoQuantization :: Maybe ByteString
, VInfoResponse -> Maybe Integer
vInfoVectorDim :: Maybe Integer
, VInfoResponse -> Maybe Integer
vInfoSize :: Maybe Integer
, VInfoResponse -> Maybe Integer
vInfoMaxLevel :: Maybe Integer
, VInfoResponse -> Maybe Integer
vInfoUid :: Maybe Integer
, VInfoResponse -> Maybe Integer
vInfoHnswMaxNodeUid :: Maybe Integer
} deriving (Int -> VInfoResponse -> ShowS
[VInfoResponse] -> ShowS
VInfoResponse -> String
(Int -> VInfoResponse -> ShowS)
-> (VInfoResponse -> String)
-> ([VInfoResponse] -> ShowS)
-> Show VInfoResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VInfoResponse -> ShowS
showsPrec :: Int -> VInfoResponse -> ShowS
$cshow :: VInfoResponse -> String
show :: VInfoResponse -> String
$cshowList :: [VInfoResponse] -> ShowS
showList :: [VInfoResponse] -> ShowS
Show, VInfoResponse -> VInfoResponse -> Bool
(VInfoResponse -> VInfoResponse -> Bool)
-> (VInfoResponse -> VInfoResponse -> Bool) -> Eq VInfoResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VInfoResponse -> VInfoResponse -> Bool
== :: VInfoResponse -> VInfoResponse -> Bool
$c/= :: VInfoResponse -> VInfoResponse -> Bool
/= :: VInfoResponse -> VInfoResponse -> Bool
Eq)
instance RedisResult VInfoResponse where
decode :: Reply -> Either Reply VInfoResponse
decode r :: Reply
r@(MultiBulk (Just [Reply]
replies)) =
[Reply] -> Either Reply [(ByteString, Reply)]
forall {a}. RedisResult a => [Reply] -> Either Reply [(a, Reply)]
parsePairs [Reply]
replies Either Reply [(ByteString, Reply)]
-> ([(ByteString, Reply)] -> Either Reply VInfoResponse)
-> Either Reply VInfoResponse
forall a b.
Either Reply a -> (a -> Either Reply b) -> Either Reply b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= [(ByteString, Reply)] -> Either Reply VInfoResponse
forall {a}. [(ByteString, Reply)] -> Either a VInfoResponse
buildInfo
where
parsePairs :: [Reply] -> Either Reply [(a, Reply)]
parsePairs [] = [(a, Reply)] -> Either Reply [(a, Reply)]
forall a b. b -> Either a b
Right []
parsePairs (Reply
keyReply:Reply
valueReply:[Reply]
rest) =
(:) ((a, Reply) -> [(a, Reply)] -> [(a, Reply)])
-> Either Reply (a, Reply)
-> Either Reply ([(a, Reply)] -> [(a, Reply)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (a -> Reply -> (a, Reply))
-> Either Reply a -> Either Reply (Reply -> (a, Reply))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
keyReply Either Reply (Reply -> (a, Reply))
-> Either Reply Reply -> Either Reply (a, Reply)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Reply
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Reply
valueReply) Either Reply ([(a, Reply)] -> [(a, Reply)])
-> Either Reply [(a, Reply)] -> Either Reply [(a, Reply)]
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Reply] -> Either Reply [(a, Reply)]
parsePairs [Reply]
rest
parsePairs [Reply]
_ = Reply -> Either Reply [(a, Reply)]
forall a b. a -> Either a b
Left Reply
r
buildInfo :: [(ByteString, Reply)] -> Either a VInfoResponse
buildInfo [(ByteString, Reply)]
pairs = VInfoResponse -> Either a VInfoResponse
forall a b. b -> Either a b
Right VInfoResponse
{ vInfoQuantization :: Maybe ByteString
vInfoQuantization = ByteString -> [(ByteString, Reply)] -> Maybe ByteString
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
lookupDecoded ByteString
"quant-type" [(ByteString, Reply)]
pairs
, vInfoVectorDim :: Maybe Integer
vInfoVectorDim = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
lookupDecoded ByteString
"vector-dim" [(ByteString, Reply)]
pairs
, vInfoSize :: Maybe Integer
vInfoSize = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
lookupDecoded ByteString
"size" [(ByteString, Reply)]
pairs
, vInfoMaxLevel :: Maybe Integer
vInfoMaxLevel = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
lookupDecoded ByteString
"max-level" [(ByteString, Reply)]
pairs
, vInfoUid :: Maybe Integer
vInfoUid = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
lookupDecoded ByteString
"vset-uid" [(ByteString, Reply)]
pairs
, vInfoHnswMaxNodeUid :: Maybe Integer
vInfoHnswMaxNodeUid = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
lookupDecoded ByteString
"hnsw-max-node-uid" [(ByteString, Reply)]
pairs
}
lookupDecoded :: RedisResult a => ByteString -> [(ByteString, Reply)] -> Maybe a
lookupDecoded :: forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
lookupDecoded ByteString
key [(ByteString, Reply)]
pairs = ByteString -> [(ByteString, Reply)] -> Maybe Reply
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
key [(ByteString, Reply)]
pairs Maybe Reply -> (Reply -> Maybe a) -> Maybe a
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Reply -> Maybe a) -> (a -> Maybe a) -> Either Reply a -> Maybe a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe a -> Reply -> Maybe a
forall a b. a -> b -> a
const Maybe a
forall a. Maybe a
Nothing) a -> Maybe a
forall a. a -> Maybe a
Just (Either Reply a -> Maybe a)
-> (Reply -> Either Reply a) -> Reply -> Maybe a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode
decode Reply
r = Reply -> Either Reply VInfoResponse
forall a b. a -> Either a b
Left Reply
r
newtype VLinksResponse = VLinksResponse
{ VLinksResponse -> [[ByteString]]
vLinksLayers :: [[ByteString]]
} deriving (Int -> VLinksResponse -> ShowS
[VLinksResponse] -> ShowS
VLinksResponse -> String
(Int -> VLinksResponse -> ShowS)
-> (VLinksResponse -> String)
-> ([VLinksResponse] -> ShowS)
-> Show VLinksResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VLinksResponse -> ShowS
showsPrec :: Int -> VLinksResponse -> ShowS
$cshow :: VLinksResponse -> String
show :: VLinksResponse -> String
$cshowList :: [VLinksResponse] -> ShowS
showList :: [VLinksResponse] -> ShowS
Show, VLinksResponse -> VLinksResponse -> Bool
(VLinksResponse -> VLinksResponse -> Bool)
-> (VLinksResponse -> VLinksResponse -> Bool) -> Eq VLinksResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VLinksResponse -> VLinksResponse -> Bool
== :: VLinksResponse -> VLinksResponse -> Bool
$c/= :: VLinksResponse -> VLinksResponse -> Bool
/= :: VLinksResponse -> VLinksResponse -> Bool
Eq)
instance RedisResult VLinksResponse where
decode :: Reply -> Either Reply VLinksResponse
decode (MultiBulk (Just [Reply]
layers)) = [[ByteString]] -> VLinksResponse
VLinksResponse ([[ByteString]] -> VLinksResponse)
-> Either Reply [[ByteString]] -> Either Reply VLinksResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Reply -> Either Reply [ByteString])
-> [Reply] -> Either Reply [[ByteString]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply [ByteString]
forall a. RedisResult a => Reply -> Either Reply a
decode [Reply]
layers
decode Reply
r = Reply -> Either Reply VLinksResponse
forall a b. a -> Either a b
Left Reply
r
newtype VLinksWithScoresResponse = VLinksWithScoresResponse
{ VLinksWithScoresResponse -> [[(ByteString, Double)]]
vLinksWithScoresLayers :: [[(ByteString, Double)]]
} deriving (Int -> VLinksWithScoresResponse -> ShowS
[VLinksWithScoresResponse] -> ShowS
VLinksWithScoresResponse -> String
(Int -> VLinksWithScoresResponse -> ShowS)
-> (VLinksWithScoresResponse -> String)
-> ([VLinksWithScoresResponse] -> ShowS)
-> Show VLinksWithScoresResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VLinksWithScoresResponse -> ShowS
showsPrec :: Int -> VLinksWithScoresResponse -> ShowS
$cshow :: VLinksWithScoresResponse -> String
show :: VLinksWithScoresResponse -> String
$cshowList :: [VLinksWithScoresResponse] -> ShowS
showList :: [VLinksWithScoresResponse] -> ShowS
Show, VLinksWithScoresResponse -> VLinksWithScoresResponse -> Bool
(VLinksWithScoresResponse -> VLinksWithScoresResponse -> Bool)
-> (VLinksWithScoresResponse -> VLinksWithScoresResponse -> Bool)
-> Eq VLinksWithScoresResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VLinksWithScoresResponse -> VLinksWithScoresResponse -> Bool
== :: VLinksWithScoresResponse -> VLinksWithScoresResponse -> Bool
$c/= :: VLinksWithScoresResponse -> VLinksWithScoresResponse -> Bool
/= :: VLinksWithScoresResponse -> VLinksWithScoresResponse -> Bool
Eq)
instance RedisResult VLinksWithScoresResponse where
decode :: Reply -> Either Reply VLinksWithScoresResponse
decode r :: Reply
r@(MultiBulk (Just [Reply]
layers)) =
[[(ByteString, Double)]] -> VLinksWithScoresResponse
VLinksWithScoresResponse ([[(ByteString, Double)]] -> VLinksWithScoresResponse)
-> Either Reply [[(ByteString, Double)]]
-> Either Reply VLinksWithScoresResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Reply -> Either Reply [(ByteString, Double)])
-> [Reply] -> Either Reply [[(ByteString, Double)]]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply [(ByteString, Double)]
forall {a} {a}.
(RedisResult a, RedisResult a) =>
Reply -> Either Reply [(a, a)]
decodeLayer [Reply]
layers
where
decodeLayer :: Reply -> Either Reply [(a, a)]
decodeLayer (MultiBulk (Just [Reply]
entries)) = [Reply] -> Either Reply [(a, a)]
forall {a} {a}.
(RedisResult a, RedisResult a) =>
[Reply] -> Either Reply [(a, a)]
pairs [Reply]
entries
decodeLayer Reply
badReply = Reply -> Either Reply [(a, a)]
forall a b. a -> Either a b
Left Reply
badReply
pairs :: [Reply] -> Either Reply [(a, a)]
pairs [] = [(a, a)] -> Either Reply [(a, a)]
forall a b. b -> Either a b
Right []
pairs (Reply
nameReply:Reply
scoreReply:[Reply]
rest) =
(:) ((a, a) -> [(a, a)] -> [(a, a)])
-> Either Reply (a, a) -> Either Reply ([(a, a)] -> [(a, a)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (a -> a -> (a, a)) -> Either Reply a -> Either Reply (a -> (a, a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
nameReply Either Reply (a -> (a, a)) -> Either Reply a -> Either Reply (a, a)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
scoreReply) Either Reply ([(a, a)] -> [(a, a)])
-> Either Reply [(a, a)] -> Either Reply [(a, a)]
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Reply] -> Either Reply [(a, a)]
pairs [Reply]
rest
pairs [Reply]
_ = Reply -> Either Reply [(a, a)]
forall a b. a -> Either a b
Left Reply
r
decode Reply
r = Reply -> Either Reply VLinksWithScoresResponse
forall a b. a -> Either a b
Left Reply
r
data VSimQuery
= VSimByElement ByteString
| VSimByFp32 ByteString
| VSimByValues (NonEmpty Double)
deriving (Int -> VSimQuery -> ShowS
[VSimQuery] -> ShowS
VSimQuery -> String
(Int -> VSimQuery -> ShowS)
-> (VSimQuery -> String)
-> ([VSimQuery] -> ShowS)
-> Show VSimQuery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VSimQuery -> ShowS
showsPrec :: Int -> VSimQuery -> ShowS
$cshow :: VSimQuery -> String
show :: VSimQuery -> String
$cshowList :: [VSimQuery] -> ShowS
showList :: [VSimQuery] -> ShowS
Show, VSimQuery -> VSimQuery -> Bool
(VSimQuery -> VSimQuery -> Bool)
-> (VSimQuery -> VSimQuery -> Bool) -> Eq VSimQuery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VSimQuery -> VSimQuery -> Bool
== :: VSimQuery -> VSimQuery -> Bool
$c/= :: VSimQuery -> VSimQuery -> Bool
/= :: VSimQuery -> VSimQuery -> Bool
Eq)
data VSimOpts = VSimOpts
{ VSimOpts -> Maybe Integer
vSimCount :: Maybe Integer
, VSimOpts -> Maybe Double
vSimEpsilon :: Maybe Double
, VSimOpts -> Maybe Integer
vSimEf :: Maybe Integer
, VSimOpts -> Maybe ByteString
vSimFilter :: Maybe ByteString
, VSimOpts -> Maybe Integer
vSimFilterEf :: Maybe Integer
, VSimOpts -> Bool
vSimTruth :: Bool
, VSimOpts -> Bool
vSimNoThread :: Bool
} deriving (Int -> VSimOpts -> ShowS
[VSimOpts] -> ShowS
VSimOpts -> String
(Int -> VSimOpts -> ShowS)
-> (VSimOpts -> String) -> ([VSimOpts] -> ShowS) -> Show VSimOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VSimOpts -> ShowS
showsPrec :: Int -> VSimOpts -> ShowS
$cshow :: VSimOpts -> String
show :: VSimOpts -> String
$cshowList :: [VSimOpts] -> ShowS
showList :: [VSimOpts] -> ShowS
Show, VSimOpts -> VSimOpts -> Bool
(VSimOpts -> VSimOpts -> Bool)
-> (VSimOpts -> VSimOpts -> Bool) -> Eq VSimOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VSimOpts -> VSimOpts -> Bool
== :: VSimOpts -> VSimOpts -> Bool
$c/= :: VSimOpts -> VSimOpts -> Bool
/= :: VSimOpts -> VSimOpts -> Bool
Eq)
defaultVSimOpts :: VSimOpts
defaultVSimOpts :: VSimOpts
defaultVSimOpts = VSimOpts
{ vSimCount :: Maybe Integer
vSimCount = Maybe Integer
forall a. Maybe a
Nothing
, vSimEpsilon :: Maybe Double
vSimEpsilon = Maybe Double
forall a. Maybe a
Nothing
, vSimEf :: Maybe Integer
vSimEf = Maybe Integer
forall a. Maybe a
Nothing
, vSimFilter :: Maybe ByteString
vSimFilter = Maybe ByteString
forall a. Maybe a
Nothing
, vSimFilterEf :: Maybe Integer
vSimFilterEf = Maybe Integer
forall a. Maybe a
Nothing
, vSimTruth :: Bool
vSimTruth = Bool
False
, vSimNoThread :: Bool
vSimNoThread = Bool
False
}
data VSimWithAttribsResult = VSimWithAttribsResult
{ VSimWithAttribsResult -> ByteString
vSimResultElement :: ByteString
, VSimWithAttribsResult -> Double
vSimResultScore :: Double
, VSimWithAttribsResult -> Maybe ByteString
vSimResultAttributes :: Maybe ByteString
} deriving (Int -> VSimWithAttribsResult -> ShowS
[VSimWithAttribsResult] -> ShowS
VSimWithAttribsResult -> String
(Int -> VSimWithAttribsResult -> ShowS)
-> (VSimWithAttribsResult -> String)
-> ([VSimWithAttribsResult] -> ShowS)
-> Show VSimWithAttribsResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VSimWithAttribsResult -> ShowS
showsPrec :: Int -> VSimWithAttribsResult -> ShowS
$cshow :: VSimWithAttribsResult -> String
show :: VSimWithAttribsResult -> String
$cshowList :: [VSimWithAttribsResult] -> ShowS
showList :: [VSimWithAttribsResult] -> ShowS
Show, VSimWithAttribsResult -> VSimWithAttribsResult -> Bool
(VSimWithAttribsResult -> VSimWithAttribsResult -> Bool)
-> (VSimWithAttribsResult -> VSimWithAttribsResult -> Bool)
-> Eq VSimWithAttribsResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VSimWithAttribsResult -> VSimWithAttribsResult -> Bool
== :: VSimWithAttribsResult -> VSimWithAttribsResult -> Bool
$c/= :: VSimWithAttribsResult -> VSimWithAttribsResult -> Bool
/= :: VSimWithAttribsResult -> VSimWithAttribsResult -> Bool
Eq)
instance RedisResult VSimWithAttribsResult where
decode :: Reply -> Either Reply VSimWithAttribsResult
decode (MultiBulk (Just [Reply
elementReply, Reply
scoreReply, Bulk Maybe ByteString
Nothing])) =
ByteString -> Double -> Maybe ByteString -> VSimWithAttribsResult
VSimWithAttribsResult
(ByteString -> Double -> Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply ByteString
-> Either
Reply (Double -> Maybe ByteString -> VSimWithAttribsResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
elementReply
Either Reply (Double -> Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply Double
-> Either Reply (Maybe ByteString -> VSimWithAttribsResult)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Double
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
scoreReply
Either Reply (Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply (Maybe ByteString)
-> Either Reply VSimWithAttribsResult
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe ByteString -> Either Reply (Maybe ByteString)
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe ByteString
forall a. Maybe a
Nothing
decode (MultiBulk (Just [Reply
elementReply, Reply
scoreReply, Reply
attributesReply])) =
ByteString -> Double -> Maybe ByteString -> VSimWithAttribsResult
VSimWithAttribsResult
(ByteString -> Double -> Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply ByteString
-> Either
Reply (Double -> Maybe ByteString -> VSimWithAttribsResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
elementReply
Either Reply (Double -> Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply Double
-> Either Reply (Maybe ByteString -> VSimWithAttribsResult)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Double
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
scoreReply
Either Reply (Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply (Maybe ByteString)
-> Either Reply VSimWithAttribsResult
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (ByteString -> Maybe ByteString)
-> Either Reply ByteString -> Either Reply (Maybe ByteString)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
attributesReply)
decode Reply
r = Reply -> Either Reply VSimWithAttribsResult
forall a b. a -> Either a b
Left Reply
r
newtype VSimWithAttribsResponse = VSimWithAttribsResponse
{ VSimWithAttribsResponse -> [VSimWithAttribsResult]
vSimWithAttribsResults :: [VSimWithAttribsResult]
} deriving (Int -> VSimWithAttribsResponse -> ShowS
[VSimWithAttribsResponse] -> ShowS
VSimWithAttribsResponse -> String
(Int -> VSimWithAttribsResponse -> ShowS)
-> (VSimWithAttribsResponse -> String)
-> ([VSimWithAttribsResponse] -> ShowS)
-> Show VSimWithAttribsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VSimWithAttribsResponse -> ShowS
showsPrec :: Int -> VSimWithAttribsResponse -> ShowS
$cshow :: VSimWithAttribsResponse -> String
show :: VSimWithAttribsResponse -> String
$cshowList :: [VSimWithAttribsResponse] -> ShowS
showList :: [VSimWithAttribsResponse] -> ShowS
Show, VSimWithAttribsResponse -> VSimWithAttribsResponse -> Bool
(VSimWithAttribsResponse -> VSimWithAttribsResponse -> Bool)
-> (VSimWithAttribsResponse -> VSimWithAttribsResponse -> Bool)
-> Eq VSimWithAttribsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VSimWithAttribsResponse -> VSimWithAttribsResponse -> Bool
== :: VSimWithAttribsResponse -> VSimWithAttribsResponse -> Bool
$c/= :: VSimWithAttribsResponse -> VSimWithAttribsResponse -> Bool
/= :: VSimWithAttribsResponse -> VSimWithAttribsResponse -> Bool
Eq)
instance RedisResult VSimWithAttribsResponse where
decode :: Reply -> Either Reply VSimWithAttribsResponse
decode r :: Reply
r@(MultiBulk (Just [Reply]
replies)) =
[VSimWithAttribsResult] -> VSimWithAttribsResponse
VSimWithAttribsResponse ([VSimWithAttribsResult] -> VSimWithAttribsResponse)
-> Either Reply [VSimWithAttribsResult]
-> Either Reply VSimWithAttribsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Reply] -> Either Reply [VSimWithAttribsResult]
triples [Reply]
replies
where
triples :: [Reply] -> Either Reply [VSimWithAttribsResult]
triples [] = [VSimWithAttribsResult] -> Either Reply [VSimWithAttribsResult]
forall a b. b -> Either a b
Right []
triples (Reply
elementReply:Reply
scoreReply:Bulk Maybe ByteString
Nothing:[Reply]
rest) = do
result <- ByteString -> Double -> Maybe ByteString -> VSimWithAttribsResult
VSimWithAttribsResult
(ByteString -> Double -> Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply ByteString
-> Either
Reply (Double -> Maybe ByteString -> VSimWithAttribsResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
elementReply
Either Reply (Double -> Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply Double
-> Either Reply (Maybe ByteString -> VSimWithAttribsResult)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Double
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
scoreReply
Either Reply (Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply (Maybe ByteString)
-> Either Reply VSimWithAttribsResult
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe ByteString -> Either Reply (Maybe ByteString)
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe ByteString
forall a. Maybe a
Nothing
(result :) <$> triples rest
triples (Reply
elementReply:Reply
scoreReply:Reply
attributesReply:[Reply]
rest) = do
result <- ByteString -> Double -> Maybe ByteString -> VSimWithAttribsResult
VSimWithAttribsResult
(ByteString -> Double -> Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply ByteString
-> Either
Reply (Double -> Maybe ByteString -> VSimWithAttribsResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
elementReply
Either Reply (Double -> Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply Double
-> Either Reply (Maybe ByteString -> VSimWithAttribsResult)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Double
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
scoreReply
Either Reply (Maybe ByteString -> VSimWithAttribsResult)
-> Either Reply (Maybe ByteString)
-> Either Reply VSimWithAttribsResult
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (ByteString -> Maybe ByteString)
-> Either Reply ByteString -> Either Reply (Maybe ByteString)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
attributesReply)
(result :) <$> triples rest
triples [Reply]
_ = Reply -> Either Reply [VSimWithAttribsResult]
forall a b. a -> Either a b
Left Reply
r
decode Reply
r = Reply -> Either Reply VSimWithAttribsResponse
forall a b. a -> Either a b
Left Reply
r
defaultVAddOpts :: VAddOpts
defaultVAddOpts :: VAddOpts
defaultVAddOpts = VAddOpts
{ vAddReduceDim :: Maybe Integer
vAddReduceDim = Maybe Integer
forall a. Maybe a
Nothing
, vAddCas :: Bool
vAddCas = Bool
False
, vAddQuantization :: Maybe VAddQuantization
vAddQuantization = Maybe VAddQuantization
forall a. Maybe a
Nothing
, vAddBuildExplorationFactor :: Maybe Integer
vAddBuildExplorationFactor = Maybe Integer
forall a. Maybe a
Nothing
, vAddAttributes :: Maybe ByteString
vAddAttributes = Maybe ByteString
forall a. Maybe a
Nothing
, vAddNumLinks :: Maybe Integer
vAddNumLinks = Maybe Integer
forall a. Maybe a
Nothing
}
vadd
:: (RedisCtx m f)
=> ByteString
-> NonEmpty Double
-> ByteString
-> m (f Bool)
vadd :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty Double -> ByteString -> m (f Bool)
vadd ByteString
key NonEmpty Double
vector ByteString
element = ByteString
-> NonEmpty Double -> ByteString -> VAddOpts -> m (f Bool)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty Double -> ByteString -> VAddOpts -> m (f Bool)
vaddOpts ByteString
key NonEmpty Double
vector ByteString
element VAddOpts
defaultVAddOpts
vaddOpts
:: (RedisCtx m f)
=> ByteString
-> NonEmpty Double
-> ByteString
-> VAddOpts
-> m (f Bool)
vaddOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty Double -> ByteString -> VAddOpts -> m (f Bool)
vaddOpts ByteString
key NonEmpty Double
vector ByteString
element VAddOpts{Bool
Maybe Integer
Maybe ByteString
Maybe VAddQuantization
vAddReduceDim :: VAddOpts -> Maybe Integer
vAddCas :: VAddOpts -> Bool
vAddQuantization :: VAddOpts -> Maybe VAddQuantization
vAddBuildExplorationFactor :: VAddOpts -> Maybe Integer
vAddAttributes :: VAddOpts -> Maybe ByteString
vAddNumLinks :: VAddOpts -> Maybe Integer
vAddReduceDim :: Maybe Integer
vAddCas :: Bool
vAddQuantization :: Maybe VAddQuantization
vAddBuildExplorationFactor :: Maybe Integer
vAddAttributes :: Maybe ByteString
vAddNumLinks :: Maybe Integer
..} =
[ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Bool)) -> [ByteString] -> m (f Bool)
forall a b. (a -> b) -> a -> b
$
[ByteString
"VADD", ByteString
key]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
reduceArg
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"VALUES", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty Double -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty Double
vector)]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (Double -> ByteString) -> [Double] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode (NonEmpty Double -> [Double]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty Double
vector)
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
element]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
casArg
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
quantizationArg
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
efArg
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
attributesArg
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
numLinksArg
where
reduceArg :: [ByteString]
reduceArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
dim -> [ByteString
"REDUCE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
dim]) Maybe Integer
vAddReduceDim
casArg :: [ByteString]
casArg = [ByteString
"CAS" | Bool
vAddCas]
quantizationArg :: [ByteString]
quantizationArg = [ByteString]
-> (VAddQuantization -> [ByteString])
-> Maybe VAddQuantization
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\VAddQuantization
quantization -> [VAddQuantization -> ByteString
forall a. RedisArg a => a -> ByteString
encode VAddQuantization
quantization]) Maybe VAddQuantization
vAddQuantization
efArg :: [ByteString]
efArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
ef -> [ByteString
"EF", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
ef]) Maybe Integer
vAddBuildExplorationFactor
attributesArg :: [ByteString]
attributesArg = [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ByteString
attributes -> [ByteString
"SETATTR", ByteString
attributes]) Maybe ByteString
vAddAttributes
numLinksArg :: [ByteString]
numLinksArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
numLinks -> [ByteString
"M", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
numLinks]) Maybe Integer
vAddNumLinks
vcard
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
vcard :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
vcard ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VCARD", ByteString
key]
vdim
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
vdim :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
vdim ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VDIM", ByteString
key]
vemb
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f [Double])
vemb :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f [Double])
vemb ByteString
key ByteString
element = [ByteString] -> m (f [Double])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VEMB", ByteString
key, ByteString
element]
vembRaw
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f (Maybe VEmbRawResponse))
vembRaw :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe VEmbRawResponse))
vembRaw ByteString
key ByteString
element = [ByteString] -> m (f (Maybe VEmbRawResponse))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VEMB", ByteString
key, ByteString
element, ByteString
"RAW"]
vgetattr
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f (Maybe ByteString))
vgetattr :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe ByteString))
vgetattr ByteString
key ByteString
element = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VGETATTR", ByteString
key, ByteString
element]
vinfo
:: (RedisCtx m f)
=> ByteString
-> m (f (Maybe VInfoResponse))
vinfo :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe VInfoResponse))
vinfo ByteString
key = [ByteString] -> m (f (Maybe VInfoResponse))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VINFO", ByteString
key]
vismember
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f Bool)
vismember :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Bool)
vismember ByteString
key ByteString
element = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VISMEMBER", ByteString
key, ByteString
element]
vlinks
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f (Maybe VLinksResponse))
vlinks :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe VLinksResponse))
vlinks ByteString
key ByteString
element = [ByteString] -> m (f (Maybe VLinksResponse))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VLINKS", ByteString
key, ByteString
element]
vlinksWithScores
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f (Maybe VLinksWithScoresResponse))
vlinksWithScores :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f (Maybe VLinksWithScoresResponse))
vlinksWithScores ByteString
key ByteString
element = [ByteString] -> m (f (Maybe VLinksWithScoresResponse))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VLINKS", ByteString
key, ByteString
element, ByteString
"WITHSCORES"]
vrandmember
:: (RedisCtx m f)
=> ByteString
-> m (f (Maybe ByteString))
vrandmember :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
vrandmember ByteString
key = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VRANDMEMBER", ByteString
key]
vrandmemberCount
:: (RedisCtx m f)
=> ByteString
-> Integer
-> m (f [ByteString])
vrandmemberCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f [ByteString])
vrandmemberCount ByteString
key Integer
count = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VRANDMEMBER", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
vrange
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> m (f [ByteString])
vrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f [ByteString])
vrange ByteString
key ByteString
start ByteString
end = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VRANGE", ByteString
key, ByteString
start, ByteString
end]
vrangeCount
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Integer
-> m (f [ByteString])
vrangeCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> Integer -> m (f [ByteString])
vrangeCount ByteString
key ByteString
start ByteString
end Integer
count =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VRANGE", ByteString
key, ByteString
start, ByteString
end, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
vrem
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f Bool)
vrem :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Bool)
vrem ByteString
key ByteString
element = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VREM", ByteString
key, ByteString
element]
vsetattr
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> m (f Bool)
vsetattr :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Bool)
vsetattr ByteString
key ByteString
element ByteString
attributes = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"VSETATTR", ByteString
key, ByteString
element, ByteString
attributes]
vsim
:: (RedisCtx m f)
=> ByteString
-> VSimQuery
-> m (f [ByteString])
vsim :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> VSimQuery -> m (f [ByteString])
vsim ByteString
key VSimQuery
query = ByteString -> VSimQuery -> VSimOpts -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> VSimQuery -> VSimOpts -> m (f [ByteString])
vsimOpts ByteString
key VSimQuery
query VSimOpts
defaultVSimOpts
vsimOpts
:: (RedisCtx m f)
=> ByteString
-> VSimQuery
-> VSimOpts
-> m (f [ByteString])
vsimOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> VSimQuery -> VSimOpts -> m (f [ByteString])
vsimOpts ByteString
key VSimQuery
query VSimOpts
opts =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [ByteString]))
-> [ByteString] -> m (f [ByteString])
forall a b. (a -> b) -> a -> b
$ [ByteString
"VSIM", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ VSimQuery -> [ByteString]
vSimQueryArgs VSimQuery
query [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ VSimOpts -> [ByteString]
vSimOptsArgs VSimOpts
opts
vsimWithScores
:: (RedisCtx m f)
=> ByteString
-> VSimQuery
-> m (f [(ByteString, Double)])
vsimWithScores :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> VSimQuery -> m (f [(ByteString, Double)])
vsimWithScores ByteString
key VSimQuery
query = ByteString -> VSimQuery -> VSimOpts -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> VSimQuery -> VSimOpts -> m (f [(ByteString, Double)])
vsimWithScoresOpts ByteString
key VSimQuery
query VSimOpts
defaultVSimOpts
vsimWithScoresOpts
:: (RedisCtx m f)
=> ByteString
-> VSimQuery
-> VSimOpts
-> m (f [(ByteString, Double)])
vsimWithScoresOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> VSimQuery -> VSimOpts -> m (f [(ByteString, Double)])
vsimWithScoresOpts ByteString
key VSimQuery
query VSimOpts
opts =
[ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [(ByteString, Double)]))
-> [ByteString] -> m (f [(ByteString, Double)])
forall a b. (a -> b) -> a -> b
$ [ByteString
"VSIM", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ VSimQuery -> [ByteString]
vSimQueryArgs VSimQuery
query [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"WITHSCORES"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ VSimOpts -> [ByteString]
vSimOptsArgs VSimOpts
opts
vsimWithScoresWithAttribs
:: (RedisCtx m f)
=> ByteString
-> VSimQuery
-> m (f VSimWithAttribsResponse)
vsimWithScoresWithAttribs :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> VSimQuery -> m (f VSimWithAttribsResponse)
vsimWithScoresWithAttribs ByteString
key VSimQuery
query =
ByteString
-> VSimQuery -> VSimOpts -> m (f VSimWithAttribsResponse)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> VSimQuery -> VSimOpts -> m (f VSimWithAttribsResponse)
vsimWithScoresWithAttribsOpts ByteString
key VSimQuery
query VSimOpts
defaultVSimOpts
vsimWithScoresWithAttribsOpts
:: (RedisCtx m f)
=> ByteString
-> VSimQuery
-> VSimOpts
-> m (f VSimWithAttribsResponse)
vsimWithScoresWithAttribsOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> VSimQuery -> VSimOpts -> m (f VSimWithAttribsResponse)
vsimWithScoresWithAttribsOpts ByteString
key VSimQuery
query VSimOpts
opts =
[ByteString] -> m (f VSimWithAttribsResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f VSimWithAttribsResponse))
-> [ByteString] -> m (f VSimWithAttribsResponse)
forall a b. (a -> b) -> a -> b
$ [ByteString
"VSIM", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ VSimQuery -> [ByteString]
vSimQueryArgs VSimQuery
query [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"WITHSCORES", ByteString
"WITHATTRIBS"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ VSimOpts -> [ByteString]
vSimOptsArgs VSimOpts
opts
vSimQueryArgs :: VSimQuery -> [ByteString]
vSimQueryArgs :: VSimQuery -> [ByteString]
vSimQueryArgs VSimQuery
query =
case VSimQuery
query of
VSimByElement ByteString
element -> [ByteString
"ELE", ByteString
element]
VSimByFp32 ByteString
rawVector -> [ByteString
"FP32", ByteString
rawVector]
VSimByValues NonEmpty Double
values ->
[ByteString
"VALUES", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty Double -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty Double
values)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (Double -> ByteString) -> [Double] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode (NonEmpty Double -> [Double]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty Double
values)
vSimOptsArgs :: VSimOpts -> [ByteString]
vSimOptsArgs :: VSimOpts -> [ByteString]
vSimOptsArgs VSimOpts{Bool
Maybe Double
Maybe Integer
Maybe ByteString
vSimCount :: VSimOpts -> Maybe Integer
vSimEpsilon :: VSimOpts -> Maybe Double
vSimEf :: VSimOpts -> Maybe Integer
vSimFilter :: VSimOpts -> Maybe ByteString
vSimFilterEf :: VSimOpts -> Maybe Integer
vSimTruth :: VSimOpts -> Bool
vSimNoThread :: VSimOpts -> Bool
vSimCount :: Maybe Integer
vSimEpsilon :: Maybe Double
vSimEf :: Maybe Integer
vSimFilter :: Maybe ByteString
vSimFilterEf :: Maybe Integer
vSimTruth :: Bool
vSimNoThread :: Bool
..} =
[ByteString]
countArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
epsilonArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
efArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
filterArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
filterEfArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
truthArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
noThreadArg
where
countArg :: [ByteString]
countArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
count -> [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]) Maybe Integer
vSimCount
epsilonArg :: [ByteString]
epsilonArg = [ByteString]
-> (Double -> [ByteString]) -> Maybe Double -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Double
epsilon -> [ByteString
"EPSILON", Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
epsilon]) Maybe Double
vSimEpsilon
efArg :: [ByteString]
efArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
ef -> [ByteString
"EF", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
ef]) Maybe Integer
vSimEf
filterArg :: [ByteString]
filterArg = [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ByteString
expression -> [ByteString
"FILTER", ByteString
expression]) Maybe ByteString
vSimFilter
filterEfArg :: [ByteString]
filterEfArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
filterEf -> [ByteString
"FILTER-EF", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
filterEf]) Maybe Integer
vSimFilterEf
truthArg :: [ByteString]
truthArg = [ByteString
"TRUTH" | Bool
vSimTruth]
noThreadArg :: [ByteString]
noThreadArg = [ByteString
"NOTHREAD" | Bool
vSimNoThread]
migrate
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Integer
-> Integer
-> m (f Status)
migrate :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> Integer -> Integer -> m (f Status)
migrate ByteString
host ByteString
port ByteString
key Integer
destinationDb Integer
timeout =
[ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"MIGRATE", ByteString
host, ByteString
port, ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
destinationDb, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeout]
data MigrateAuth
= MigrateAuth ByteString
| MigrateAuth2 ByteString ByteString
deriving (Int -> MigrateAuth -> ShowS
[MigrateAuth] -> ShowS
MigrateAuth -> String
(Int -> MigrateAuth -> ShowS)
-> (MigrateAuth -> String)
-> ([MigrateAuth] -> ShowS)
-> Show MigrateAuth
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MigrateAuth -> ShowS
showsPrec :: Int -> MigrateAuth -> ShowS
$cshow :: MigrateAuth -> String
show :: MigrateAuth -> String
$cshowList :: [MigrateAuth] -> ShowS
showList :: [MigrateAuth] -> ShowS
Show, MigrateAuth -> MigrateAuth -> Bool
(MigrateAuth -> MigrateAuth -> Bool)
-> (MigrateAuth -> MigrateAuth -> Bool) -> Eq MigrateAuth
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MigrateAuth -> MigrateAuth -> Bool
== :: MigrateAuth -> MigrateAuth -> Bool
$c/= :: MigrateAuth -> MigrateAuth -> Bool
/= :: MigrateAuth -> MigrateAuth -> Bool
Eq)
data MigrateOpts = MigrateOpts
{ MigrateOpts -> Bool
migrateCopy :: Bool
, MigrateOpts -> Bool
migrateReplace :: Bool
, MigrateOpts -> Maybe MigrateAuth
migrateAuth :: Maybe MigrateAuth
} deriving (Int -> MigrateOpts -> ShowS
[MigrateOpts] -> ShowS
MigrateOpts -> String
(Int -> MigrateOpts -> ShowS)
-> (MigrateOpts -> String)
-> ([MigrateOpts] -> ShowS)
-> Show MigrateOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MigrateOpts -> ShowS
showsPrec :: Int -> MigrateOpts -> ShowS
$cshow :: MigrateOpts -> String
show :: MigrateOpts -> String
$cshowList :: [MigrateOpts] -> ShowS
showList :: [MigrateOpts] -> ShowS
Show, MigrateOpts -> MigrateOpts -> Bool
(MigrateOpts -> MigrateOpts -> Bool)
-> (MigrateOpts -> MigrateOpts -> Bool) -> Eq MigrateOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MigrateOpts -> MigrateOpts -> Bool
== :: MigrateOpts -> MigrateOpts -> Bool
$c/= :: MigrateOpts -> MigrateOpts -> Bool
/= :: MigrateOpts -> MigrateOpts -> Bool
Eq)
defaultMigrateOpts :: MigrateOpts
defaultMigrateOpts :: MigrateOpts
defaultMigrateOpts = MigrateOpts
{ migrateCopy :: Bool
migrateCopy = Bool
False
, migrateReplace :: Bool
migrateReplace = Bool
False
, migrateAuth :: Maybe MigrateAuth
migrateAuth = Maybe MigrateAuth
forall a. Maybe a
Nothing
}
migrateMultiple
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> Integer
-> Integer
-> MigrateOpts
-> [ByteString]
-> m (f Status)
migrateMultiple :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> Integer
-> Integer
-> MigrateOpts
-> [ByteString]
-> m (f Status)
migrateMultiple ByteString
host ByteString
port Integer
destinationDb Integer
timeout MigrateOpts{Bool
Maybe MigrateAuth
migrateCopy :: MigrateOpts -> Bool
migrateReplace :: MigrateOpts -> Bool
migrateAuth :: MigrateOpts -> Maybe MigrateAuth
migrateCopy :: Bool
migrateReplace :: Bool
migrateAuth :: Maybe MigrateAuth
..} [ByteString]
keys =
[ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$
[[ByteString]] -> [ByteString]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[ByteString
"MIGRATE", ByteString
host, ByteString
port, ByteString
empty, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
destinationDb, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeout],
[ByteString]
auth_, [ByteString]
copyArg, [ByteString]
replace, [ByteString]
keys]
where
copyArg :: [ByteString]
copyArg = [ByteString
"COPY" | Bool
migrateCopy]
replace :: [ByteString]
replace = [ByteString
"REPLACE" | Bool
migrateReplace]
auth_ :: [ByteString]
auth_ = case Maybe MigrateAuth
migrateAuth of
Maybe MigrateAuth
Nothing -> []
Just (MigrateAuth ByteString
pass) -> [ByteString
"AUTH", ByteString
pass]
Just (MigrateAuth2 ByteString
user ByteString
pass) -> [ByteString
"AUTH2", ByteString
user, ByteString
pass]
restore
:: (RedisCtx m f)
=> ByteString
-> Integer
-> ByteString
-> m (f Status)
restore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ByteString -> m (f Status)
restore ByteString
key Integer
timeToLive ByteString
serializedValue =
[ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"RESTORE", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeToLive, ByteString
serializedValue]
data RestoreOpts = RestoreOpts
{ RestoreOpts -> Bool
restoreOptsReplace :: Bool
, RestoreOpts -> Bool
restoreOptsAbsTTL :: Bool
, RestoreOpts -> Maybe Integer
restoreOptsIdle :: Maybe Integer
, RestoreOpts -> Maybe Integer
restoreOptsFreq :: Maybe Integer
}
restoreOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> ByteString
-> RestoreOpts
-> m (f Status)
restoreOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ByteString -> RestoreOpts -> m (f Status)
restoreOpts ByteString
key Integer
timeToLive ByteString
serializedValue RestoreOpts{Bool
Maybe Integer
restoreOptsReplace :: RestoreOpts -> Bool
restoreOptsAbsTTL :: RestoreOpts -> Bool
restoreOptsIdle :: RestoreOpts -> Maybe Integer
restoreOptsFreq :: RestoreOpts -> Maybe Integer
restoreOptsReplace :: Bool
restoreOptsAbsTTL :: Bool
restoreOptsIdle :: Maybe Integer
restoreOptsFreq :: Maybe Integer
..} =
[ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"RESTORE"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
keyByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeToLiveByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
serializedValueByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[ByteString]
rest) where
rest :: [ByteString]
rest = [ByteString]
replace [ByteString] -> [ByteString] -> [ByteString]
forall a. Semigroup a => a -> a -> a
<> [ByteString]
absttl [ByteString] -> [ByteString] -> [ByteString]
forall a. Semigroup a => a -> a -> a
<> [ByteString]
idle [ByteString] -> [ByteString] -> [ByteString]
forall a. Semigroup a => a -> a -> a
<> [ByteString]
freq
replace :: [ByteString]
replace = [ByteString
"REPLACE" | Bool
restoreOptsReplace]
absttl :: [ByteString]
absttl = [ByteString
"ABSTTL" | Bool
restoreOptsAbsTTL]
idle :: [ByteString]
idle = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
i -> [ByteString
"IDLE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
i]) Maybe Integer
restoreOptsIdle
freq :: [ByteString]
freq = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
f -> [ByteString
"FREQ", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
f]) Maybe Integer
restoreOptsFreq
restoreReplace
:: (RedisCtx m f)
=> ByteString
-> Integer
-> ByteString
-> m (f Status)
restoreReplace :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ByteString -> m (f Status)
restoreReplace ByteString
key Integer
timeToLive ByteString
serializedValue =
[ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"RESTORE", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timeToLive, ByteString
serializedValue, ByteString
"REPLACE"]
data CopyOpts = CopyOpts
{ CopyOpts -> Maybe Integer
copyDestinationDb :: Maybe Integer
, CopyOpts -> Bool
copyReplace :: Bool
} deriving (Int -> CopyOpts -> ShowS
[CopyOpts] -> ShowS
CopyOpts -> String
(Int -> CopyOpts -> ShowS)
-> (CopyOpts -> String) -> ([CopyOpts] -> ShowS) -> Show CopyOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CopyOpts -> ShowS
showsPrec :: Int -> CopyOpts -> ShowS
$cshow :: CopyOpts -> String
show :: CopyOpts -> String
$cshowList :: [CopyOpts] -> ShowS
showList :: [CopyOpts] -> ShowS
Show, CopyOpts -> CopyOpts -> Bool
(CopyOpts -> CopyOpts -> Bool)
-> (CopyOpts -> CopyOpts -> Bool) -> Eq CopyOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CopyOpts -> CopyOpts -> Bool
== :: CopyOpts -> CopyOpts -> Bool
$c/= :: CopyOpts -> CopyOpts -> Bool
/= :: CopyOpts -> CopyOpts -> Bool
Eq)
defaultCopyOpts :: CopyOpts
defaultCopyOpts :: CopyOpts
defaultCopyOpts = CopyOpts
{ copyDestinationDb :: Maybe Integer
copyDestinationDb = Maybe Integer
forall a. Maybe a
Nothing
, copyReplace :: Bool
copyReplace = Bool
False
}
copy
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f Bool)
copy :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Bool)
copy ByteString
source ByteString
destination = ByteString -> ByteString -> CopyOpts -> m (f Bool)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> CopyOpts -> m (f Bool)
copyOpts ByteString
source ByteString
destination CopyOpts
defaultCopyOpts
copyOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> CopyOpts
-> m (f Bool)
copyOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> CopyOpts -> m (f Bool)
copyOpts ByteString
source ByteString
destination CopyOpts{Bool
Maybe Integer
copyDestinationDb :: CopyOpts -> Maybe Integer
copyReplace :: CopyOpts -> Bool
copyDestinationDb :: Maybe Integer
copyReplace :: Bool
..} =
[ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Bool)) -> [ByteString] -> m (f Bool)
forall a b. (a -> b) -> a -> b
$ [ByteString
"COPY", ByteString
source, ByteString
destination] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
dbArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
replaceArg
where
dbArg :: [ByteString]
dbArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
destinationDb -> [ByteString
"DB", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
destinationDb]) Maybe Integer
copyDestinationDb
replaceArg :: [ByteString]
replaceArg = [ByteString
"REPLACE" | Bool
copyReplace]
expiretime
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
expiretime :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
expiretime ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"EXPIRETIME", ByteString
key]
pexpiretime
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
pexpiretime :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
pexpiretime ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"PEXPIRETIME", ByteString
key]
set
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f Status)
set :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Status)
set ByteString
key ByteString
value = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SET", ByteString
key, ByteString
value]
data Condition =
Nx |
Xx
deriving (Int -> Condition -> ShowS
[Condition] -> ShowS
Condition -> String
(Int -> Condition -> ShowS)
-> (Condition -> String)
-> ([Condition] -> ShowS)
-> Show Condition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Condition -> ShowS
showsPrec :: Int -> Condition -> ShowS
$cshow :: Condition -> String
show :: Condition -> String
$cshowList :: [Condition] -> ShowS
showList :: [Condition] -> ShowS
Show, Condition -> Condition -> Bool
(Condition -> Condition -> Bool)
-> (Condition -> Condition -> Bool) -> Eq Condition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Condition -> Condition -> Bool
== :: Condition -> Condition -> Bool
$c/= :: Condition -> Condition -> Bool
/= :: Condition -> Condition -> Bool
Eq)
instance RedisArg Condition where
encode :: Condition -> ByteString
encode Condition
Nx = ByteString
"NX"
encode Condition
Xx = ByteString
"XX"
data SetOpts = SetOpts
{ SetOpts -> Maybe Integer
setSeconds :: Maybe Integer
, SetOpts -> Maybe Integer
setMilliseconds :: Maybe Integer
, SetOpts -> Maybe Integer
setUnixSeconds :: Maybe Integer
, SetOpts -> Maybe Integer
setUnixMilliseconds :: Maybe Integer
, SetOpts -> Maybe Condition
setCondition :: Maybe Condition
, SetOpts -> Bool
setKeepTTL :: Bool
} deriving (Int -> SetOpts -> ShowS
[SetOpts] -> ShowS
SetOpts -> String
(Int -> SetOpts -> ShowS)
-> (SetOpts -> String) -> ([SetOpts] -> ShowS) -> Show SetOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetOpts -> ShowS
showsPrec :: Int -> SetOpts -> ShowS
$cshow :: SetOpts -> String
show :: SetOpts -> String
$cshowList :: [SetOpts] -> ShowS
showList :: [SetOpts] -> ShowS
Show, SetOpts -> SetOpts -> Bool
(SetOpts -> SetOpts -> Bool)
-> (SetOpts -> SetOpts -> Bool) -> Eq SetOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetOpts -> SetOpts -> Bool
== :: SetOpts -> SetOpts -> Bool
$c/= :: SetOpts -> SetOpts -> Bool
/= :: SetOpts -> SetOpts -> Bool
Eq)
defaultSetOpts :: SetOpts
defaultSetOpts :: SetOpts
defaultSetOpts = SetOpts
{ setSeconds :: Maybe Integer
setSeconds = Maybe Integer
forall a. Maybe a
Nothing
, setMilliseconds :: Maybe Integer
setMilliseconds = Maybe Integer
forall a. Maybe a
Nothing
, setUnixSeconds :: Maybe Integer
setUnixSeconds = Maybe Integer
forall a. Maybe a
Nothing
, setUnixMilliseconds :: Maybe Integer
setUnixMilliseconds = Maybe Integer
forall a. Maybe a
Nothing
, setCondition :: Maybe Condition
setCondition = Maybe Condition
forall a. Maybe a
Nothing
, setKeepTTL :: Bool
setKeepTTL = Bool
False
}
internalSetOptsToArgs :: SetOpts -> [ByteString]
internalSetOptsToArgs :: SetOpts -> [ByteString]
internalSetOptsToArgs SetOpts{Bool
Maybe Integer
Maybe Condition
setSeconds :: SetOpts -> Maybe Integer
setMilliseconds :: SetOpts -> Maybe Integer
setUnixSeconds :: SetOpts -> Maybe Integer
setUnixMilliseconds :: SetOpts -> Maybe Integer
setCondition :: SetOpts -> Maybe Condition
setKeepTTL :: SetOpts -> Bool
setSeconds :: Maybe Integer
setMilliseconds :: Maybe Integer
setUnixSeconds :: Maybe Integer
setUnixMilliseconds :: Maybe Integer
setCondition :: Maybe Condition
setKeepTTL :: Bool
..} = [[ByteString]] -> [ByteString]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[ByteString]
ex, [ByteString]
px, [ByteString]
exat, [ByteString]
pxat, [ByteString]
keepttl, [ByteString]
condition]
where
ex :: [ByteString]
ex = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
s -> [ByteString
"EX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
s]) Maybe Integer
setSeconds
px :: [ByteString]
px = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
s -> [ByteString
"PX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
s]) Maybe Integer
setMilliseconds
exat :: [ByteString]
exat = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
s -> [ByteString
"EXAT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
s]) Maybe Integer
setUnixSeconds
pxat :: [ByteString]
pxat = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
s -> [ByteString
"PXAT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
s]) Maybe Integer
setUnixMilliseconds
keepttl :: [ByteString]
keepttl = [ByteString
"KEEPTTL" | Bool
setKeepTTL]
condition :: [ByteString]
condition = (Condition -> ByteString) -> [Condition] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Condition -> ByteString
forall a. RedisArg a => a -> ByteString
encode ([Condition] -> [ByteString]) -> [Condition] -> [ByteString]
forall a b. (a -> b) -> a -> b
$ Maybe Condition -> [Condition]
forall a. Maybe a -> [a]
maybeToList Maybe Condition
setCondition
setOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> SetOpts
-> m (f Status)
setOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> SetOpts -> m (f Status)
setOpts ByteString
key ByteString
value SetOpts
opts = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$ [ByteString
"SET", ByteString
key, ByteString
value] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ SetOpts -> [ByteString]
internalSetOptsToArgs SetOpts
opts
setGet
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f ByteString)
setGet :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f ByteString)
setGet ByteString
key ByteString
value = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SET", ByteString
key, ByteString
value, ByteString
"GET"]
setGetOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> SetOpts
-> m (f ByteString)
setGetOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> SetOpts -> m (f ByteString)
setGetOpts ByteString
key ByteString
value SetOpts
opts = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f ByteString))
-> [ByteString] -> m (f ByteString)
forall a b. (a -> b) -> a -> b
$ [ByteString
"SET", ByteString
key, ByteString
value, ByteString
"GET"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ SetOpts -> [ByteString]
internalSetOptsToArgs SetOpts
opts
msetex
:: (RedisCtx m f)
=> NonEmpty (ByteString, ByteString)
-> m (f Bool)
msetex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty (ByteString, ByteString) -> m (f Bool)
msetex NonEmpty (ByteString, ByteString)
keyValues = NonEmpty (ByteString, ByteString) -> SetOpts -> m (f Bool)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty (ByteString, ByteString) -> SetOpts -> m (f Bool)
msetexOpts NonEmpty (ByteString, ByteString)
keyValues SetOpts
defaultSetOpts
msetexOpts
:: (RedisCtx m f)
=> NonEmpty (ByteString, ByteString)
-> SetOpts
-> m (f Bool)
msetexOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty (ByteString, ByteString) -> SetOpts -> m (f Bool)
msetexOpts NonEmpty (ByteString, ByteString)
keyValues SetOpts
opts =
[ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Bool)) -> [ByteString] -> m (f Bool)
forall a b. (a -> b) -> a -> b
$
[ByteString
"MSETEX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty (ByteString, ByteString) -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty (ByteString, ByteString)
keyValues)]
[ByteString] -> [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
key, ByteString
value) -> [ByteString
key, ByteString
value]) (NonEmpty (ByteString, ByteString) -> [(ByteString, ByteString)]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty (ByteString, ByteString)
keyValues)
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ SetOpts -> [ByteString]
internalSetOptsToArgs SetOpts
opts
data GetExOpts = GetExOpts
{ GetExOpts -> Maybe Integer
getExSeconds :: Maybe Integer
, GetExOpts -> Maybe Integer
getExMilliseconds :: Maybe Integer
, GetExOpts -> Maybe Integer
getExUnixSeconds :: Maybe Integer
, GetExOpts -> Maybe Integer
getExUnixMilliseconds :: Maybe Integer
, GetExOpts -> Bool
getExPersist :: Bool
} deriving (Int -> GetExOpts -> ShowS
[GetExOpts] -> ShowS
GetExOpts -> String
(Int -> GetExOpts -> ShowS)
-> (GetExOpts -> String)
-> ([GetExOpts] -> ShowS)
-> Show GetExOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetExOpts -> ShowS
showsPrec :: Int -> GetExOpts -> ShowS
$cshow :: GetExOpts -> String
show :: GetExOpts -> String
$cshowList :: [GetExOpts] -> ShowS
showList :: [GetExOpts] -> ShowS
Show, GetExOpts -> GetExOpts -> Bool
(GetExOpts -> GetExOpts -> Bool)
-> (GetExOpts -> GetExOpts -> Bool) -> Eq GetExOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetExOpts -> GetExOpts -> Bool
== :: GetExOpts -> GetExOpts -> Bool
$c/= :: GetExOpts -> GetExOpts -> Bool
/= :: GetExOpts -> GetExOpts -> Bool
Eq)
defaultGetExOpts :: GetExOpts
defaultGetExOpts :: GetExOpts
defaultGetExOpts = GetExOpts
{ getExSeconds :: Maybe Integer
getExSeconds = Maybe Integer
forall a. Maybe a
Nothing
, getExMilliseconds :: Maybe Integer
getExMilliseconds = Maybe Integer
forall a. Maybe a
Nothing
, getExUnixSeconds :: Maybe Integer
getExUnixSeconds = Maybe Integer
forall a. Maybe a
Nothing
, getExUnixMilliseconds :: Maybe Integer
getExUnixMilliseconds = Maybe Integer
forall a. Maybe a
Nothing
, getExPersist :: Bool
getExPersist = Bool
False
}
getdel
:: (RedisCtx m f)
=> ByteString
-> m (f (Maybe ByteString))
getdel :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
getdel ByteString
key = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"GETDEL", ByteString
key]
data DelexCondition
= DelexIfEq ByteString
| DelexIfNe ByteString
| DelexIfDigestEq ByteString
| DelexIfDigestNe ByteString
deriving (Int -> DelexCondition -> ShowS
[DelexCondition] -> ShowS
DelexCondition -> String
(Int -> DelexCondition -> ShowS)
-> (DelexCondition -> String)
-> ([DelexCondition] -> ShowS)
-> Show DelexCondition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DelexCondition -> ShowS
showsPrec :: Int -> DelexCondition -> ShowS
$cshow :: DelexCondition -> String
show :: DelexCondition -> String
$cshowList :: [DelexCondition] -> ShowS
showList :: [DelexCondition] -> ShowS
Show, DelexCondition -> DelexCondition -> Bool
(DelexCondition -> DelexCondition -> Bool)
-> (DelexCondition -> DelexCondition -> Bool) -> Eq DelexCondition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DelexCondition -> DelexCondition -> Bool
== :: DelexCondition -> DelexCondition -> Bool
$c/= :: DelexCondition -> DelexCondition -> Bool
/= :: DelexCondition -> DelexCondition -> Bool
Eq)
delexConditionToArgs :: DelexCondition -> [ByteString]
delexConditionToArgs :: DelexCondition -> [ByteString]
delexConditionToArgs DelexCondition
condition =
case DelexCondition
condition of
DelexIfEq ByteString
value -> [ByteString
"IFEQ", ByteString
value]
DelexIfNe ByteString
value -> [ByteString
"IFNE", ByteString
value]
DelexIfDigestEq ByteString
digestValue -> [ByteString
"IFDEQ", ByteString
digestValue]
DelexIfDigestNe ByteString
digestValue -> [ByteString
"IFDNE", ByteString
digestValue]
delex
:: (RedisCtx m f)
=> ByteString
-> m (f Bool)
delex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Bool)
delex ByteString
key = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"DELEX", ByteString
key]
delexWhen
:: (RedisCtx m f)
=> ByteString
-> DelexCondition
-> m (f Bool)
delexWhen :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> DelexCondition -> m (f Bool)
delexWhen ByteString
key DelexCondition
condition =
[ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Bool)) -> [ByteString] -> m (f Bool)
forall a b. (a -> b) -> a -> b
$ [ByteString
"DELEX", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ DelexCondition -> [ByteString]
delexConditionToArgs DelexCondition
condition
digest
:: (RedisCtx m f)
=> ByteString
-> m (f (Maybe ByteString))
digest :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
digest ByteString
key = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"DIGEST", ByteString
key]
getex
:: (RedisCtx m f)
=> ByteString
-> m (f (Maybe ByteString))
getex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
getex ByteString
key = ByteString -> GetExOpts -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> GetExOpts -> m (f (Maybe ByteString))
getexOpts ByteString
key GetExOpts
defaultGetExOpts
getexOpts
:: (RedisCtx m f)
=> ByteString
-> GetExOpts
-> m (f (Maybe ByteString))
getexOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> GetExOpts -> m (f (Maybe ByteString))
getexOpts ByteString
key GetExOpts{Bool
Maybe Integer
getExSeconds :: GetExOpts -> Maybe Integer
getExMilliseconds :: GetExOpts -> Maybe Integer
getExUnixSeconds :: GetExOpts -> Maybe Integer
getExUnixMilliseconds :: GetExOpts -> Maybe Integer
getExPersist :: GetExOpts -> Bool
getExSeconds :: Maybe Integer
getExMilliseconds :: Maybe Integer
getExUnixSeconds :: Maybe Integer
getExUnixMilliseconds :: Maybe Integer
getExPersist :: Bool
..} =
[ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe ByteString)))
-> [ByteString] -> m (f (Maybe ByteString))
forall a b. (a -> b) -> a -> b
$ [ByteString
"GETEX", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
exArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
pxArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
exatArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
pxatArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
persistArg
where
exArg :: [ByteString]
exArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
seconds -> [ByteString
"EX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds]) Maybe Integer
getExSeconds
pxArg :: [ByteString]
pxArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
milliseconds -> [ByteString
"PX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds]) Maybe Integer
getExMilliseconds
exatArg :: [ByteString]
exatArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
seconds -> [ByteString
"EXAT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds]) Maybe Integer
getExUnixSeconds
pxatArg :: [ByteString]
pxatArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
milliseconds -> [ByteString
"PXAT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds]) Maybe Integer
getExUnixMilliseconds
persistArg :: [ByteString]
persistArg = [ByteString
"PERSIST" | Bool
getExPersist]
data HGetExOpts = HGetExOpts
{ HGetExOpts -> Maybe Integer
hGetExSeconds :: Maybe Integer
, HGetExOpts -> Maybe Integer
hGetExMilliseconds :: Maybe Integer
, HGetExOpts -> Maybe Integer
hGetExUnixSeconds :: Maybe Integer
, HGetExOpts -> Maybe Integer
hGetExUnixMilliseconds :: Maybe Integer
, HGetExOpts -> Bool
hGetExPersist :: Bool
} deriving (Int -> HGetExOpts -> ShowS
[HGetExOpts] -> ShowS
HGetExOpts -> String
(Int -> HGetExOpts -> ShowS)
-> (HGetExOpts -> String)
-> ([HGetExOpts] -> ShowS)
-> Show HGetExOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HGetExOpts -> ShowS
showsPrec :: Int -> HGetExOpts -> ShowS
$cshow :: HGetExOpts -> String
show :: HGetExOpts -> String
$cshowList :: [HGetExOpts] -> ShowS
showList :: [HGetExOpts] -> ShowS
Show, HGetExOpts -> HGetExOpts -> Bool
(HGetExOpts -> HGetExOpts -> Bool)
-> (HGetExOpts -> HGetExOpts -> Bool) -> Eq HGetExOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HGetExOpts -> HGetExOpts -> Bool
== :: HGetExOpts -> HGetExOpts -> Bool
$c/= :: HGetExOpts -> HGetExOpts -> Bool
/= :: HGetExOpts -> HGetExOpts -> Bool
Eq)
defaultHGetExOpts :: HGetExOpts
defaultHGetExOpts :: HGetExOpts
defaultHGetExOpts = HGetExOpts
{ hGetExSeconds :: Maybe Integer
hGetExSeconds = Maybe Integer
forall a. Maybe a
Nothing
, hGetExMilliseconds :: Maybe Integer
hGetExMilliseconds = Maybe Integer
forall a. Maybe a
Nothing
, hGetExUnixSeconds :: Maybe Integer
hGetExUnixSeconds = Maybe Integer
forall a. Maybe a
Nothing
, hGetExUnixMilliseconds :: Maybe Integer
hGetExUnixMilliseconds = Maybe Integer
forall a. Maybe a
Nothing
, hGetExPersist :: Bool
hGetExPersist = Bool
False
}
hgetex
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f [Maybe ByteString])
hgetex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f [Maybe ByteString])
hgetex ByteString
key NonEmpty ByteString
fields = ByteString
-> NonEmpty ByteString -> HGetExOpts -> m (f [Maybe ByteString])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty ByteString -> HGetExOpts -> m (f [Maybe ByteString])
hgetexOpts ByteString
key NonEmpty ByteString
fields HGetExOpts
defaultHGetExOpts
hgetexOpts
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> HGetExOpts
-> m (f [Maybe ByteString])
hgetexOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty ByteString -> HGetExOpts -> m (f [Maybe ByteString])
hgetexOpts ByteString
key NonEmpty ByteString
fields HGetExOpts{Bool
Maybe Integer
hGetExSeconds :: HGetExOpts -> Maybe Integer
hGetExMilliseconds :: HGetExOpts -> Maybe Integer
hGetExUnixSeconds :: HGetExOpts -> Maybe Integer
hGetExUnixMilliseconds :: HGetExOpts -> Maybe Integer
hGetExPersist :: HGetExOpts -> Bool
hGetExSeconds :: Maybe Integer
hGetExMilliseconds :: Maybe Integer
hGetExUnixSeconds :: Maybe Integer
hGetExUnixMilliseconds :: Maybe Integer
hGetExPersist :: Bool
..} =
[ByteString] -> m (f [Maybe ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [Maybe ByteString]))
-> [ByteString] -> m (f [Maybe ByteString])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HGETEX", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
exArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
pxArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
exatArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
pxatArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
persistArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
where
exArg :: [ByteString]
exArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
seconds -> [ByteString
"EX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds]) Maybe Integer
hGetExSeconds
pxArg :: [ByteString]
pxArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
milliseconds -> [ByteString
"PX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds]) Maybe Integer
hGetExMilliseconds
exatArg :: [ByteString]
exatArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
seconds -> [ByteString
"EXAT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds]) Maybe Integer
hGetExUnixSeconds
pxatArg :: [ByteString]
pxatArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
milliseconds -> [ByteString
"PXAT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds]) Maybe Integer
hGetExUnixMilliseconds
persistArg :: [ByteString]
persistArg = [ByteString
"PERSIST" | Bool
hGetExPersist]
hgetdel
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f [Maybe ByteString])
hgetdel :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f [Maybe ByteString])
hgetdel ByteString
key NonEmpty ByteString
fields =
[ByteString] -> m (f [Maybe ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [Maybe ByteString]))
-> [ByteString] -> m (f [Maybe ByteString])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HGETDEL", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
data HSetExCondition = HSetExFnx | HSetExFxx deriving (Int -> HSetExCondition -> ShowS
[HSetExCondition] -> ShowS
HSetExCondition -> String
(Int -> HSetExCondition -> ShowS)
-> (HSetExCondition -> String)
-> ([HSetExCondition] -> ShowS)
-> Show HSetExCondition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HSetExCondition -> ShowS
showsPrec :: Int -> HSetExCondition -> ShowS
$cshow :: HSetExCondition -> String
show :: HSetExCondition -> String
$cshowList :: [HSetExCondition] -> ShowS
showList :: [HSetExCondition] -> ShowS
Show, HSetExCondition -> HSetExCondition -> Bool
(HSetExCondition -> HSetExCondition -> Bool)
-> (HSetExCondition -> HSetExCondition -> Bool)
-> Eq HSetExCondition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HSetExCondition -> HSetExCondition -> Bool
== :: HSetExCondition -> HSetExCondition -> Bool
$c/= :: HSetExCondition -> HSetExCondition -> Bool
/= :: HSetExCondition -> HSetExCondition -> Bool
Eq)
instance RedisArg HSetExCondition where
encode :: HSetExCondition -> ByteString
encode HSetExCondition
HSetExFnx = ByteString
"FNX"
encode HSetExCondition
HSetExFxx = ByteString
"FXX"
data HSetExOpts = HSetExOpts
{ HSetExOpts -> Maybe Integer
hSetExSeconds :: Maybe Integer
, HSetExOpts -> Maybe Integer
hSetExMilliseconds :: Maybe Integer
, HSetExOpts -> Maybe Integer
hSetExUnixSeconds :: Maybe Integer
, HSetExOpts -> Maybe Integer
hSetExUnixMilliseconds :: Maybe Integer
, HSetExOpts -> Maybe HSetExCondition
hSetExCondition :: Maybe HSetExCondition
, HSetExOpts -> Bool
hSetExKeepTTL :: Bool
} deriving (Int -> HSetExOpts -> ShowS
[HSetExOpts] -> ShowS
HSetExOpts -> String
(Int -> HSetExOpts -> ShowS)
-> (HSetExOpts -> String)
-> ([HSetExOpts] -> ShowS)
-> Show HSetExOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HSetExOpts -> ShowS
showsPrec :: Int -> HSetExOpts -> ShowS
$cshow :: HSetExOpts -> String
show :: HSetExOpts -> String
$cshowList :: [HSetExOpts] -> ShowS
showList :: [HSetExOpts] -> ShowS
Show, HSetExOpts -> HSetExOpts -> Bool
(HSetExOpts -> HSetExOpts -> Bool)
-> (HSetExOpts -> HSetExOpts -> Bool) -> Eq HSetExOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HSetExOpts -> HSetExOpts -> Bool
== :: HSetExOpts -> HSetExOpts -> Bool
$c/= :: HSetExOpts -> HSetExOpts -> Bool
/= :: HSetExOpts -> HSetExOpts -> Bool
Eq)
defaultHSetExOpts :: HSetExOpts
defaultHSetExOpts :: HSetExOpts
defaultHSetExOpts = HSetExOpts
{ hSetExSeconds :: Maybe Integer
hSetExSeconds = Maybe Integer
forall a. Maybe a
Nothing
, hSetExMilliseconds :: Maybe Integer
hSetExMilliseconds = Maybe Integer
forall a. Maybe a
Nothing
, hSetExUnixSeconds :: Maybe Integer
hSetExUnixSeconds = Maybe Integer
forall a. Maybe a
Nothing
, hSetExUnixMilliseconds :: Maybe Integer
hSetExUnixMilliseconds = Maybe Integer
forall a. Maybe a
Nothing
, hSetExCondition :: Maybe HSetExCondition
hSetExCondition = Maybe HSetExCondition
forall a. Maybe a
Nothing
, hSetExKeepTTL :: Bool
hSetExKeepTTL = Bool
False
}
hsetex
:: (RedisCtx m f)
=> ByteString
-> NonEmpty (ByteString, ByteString)
-> m (f Bool)
hsetex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty (ByteString, ByteString) -> m (f Bool)
hsetex ByteString
key NonEmpty (ByteString, ByteString)
fieldValues = ByteString
-> NonEmpty (ByteString, ByteString) -> HSetExOpts -> m (f Bool)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty (ByteString, ByteString) -> HSetExOpts -> m (f Bool)
hsetexOpts ByteString
key NonEmpty (ByteString, ByteString)
fieldValues HSetExOpts
defaultHSetExOpts
hsetexOpts
:: (RedisCtx m f)
=> ByteString
-> NonEmpty (ByteString, ByteString)
-> HSetExOpts
-> m (f Bool)
hsetexOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty (ByteString, ByteString) -> HSetExOpts -> m (f Bool)
hsetexOpts ByteString
key NonEmpty (ByteString, ByteString)
fieldValues HSetExOpts{Bool
Maybe Integer
Maybe HSetExCondition
hSetExSeconds :: HSetExOpts -> Maybe Integer
hSetExMilliseconds :: HSetExOpts -> Maybe Integer
hSetExUnixSeconds :: HSetExOpts -> Maybe Integer
hSetExUnixMilliseconds :: HSetExOpts -> Maybe Integer
hSetExCondition :: HSetExOpts -> Maybe HSetExCondition
hSetExKeepTTL :: HSetExOpts -> Bool
hSetExSeconds :: Maybe Integer
hSetExMilliseconds :: Maybe Integer
hSetExUnixSeconds :: Maybe Integer
hSetExUnixMilliseconds :: Maybe Integer
hSetExCondition :: Maybe HSetExCondition
hSetExKeepTTL :: Bool
..} =
[ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Bool)) -> [ByteString] -> m (f Bool)
forall a b. (a -> b) -> a -> b
$ [ByteString
"HSETEX", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
conditionArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
exArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
pxArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
exatArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
pxatArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
keepTTLArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"FIELDS", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty (ByteString, ByteString) -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty (ByteString, ByteString)
fieldValues)] [ByteString] -> [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
field, ByteString
value) -> [ByteString
field, ByteString
value]) (NonEmpty (ByteString, ByteString) -> [(ByteString, ByteString)]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty (ByteString, ByteString)
fieldValues)
where
conditionArg :: [ByteString]
conditionArg = [ByteString]
-> (HSetExCondition -> [ByteString])
-> Maybe HSetExCondition
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\HSetExCondition
condition -> [HSetExCondition -> ByteString
forall a. RedisArg a => a -> ByteString
encode HSetExCondition
condition]) Maybe HSetExCondition
hSetExCondition
exArg :: [ByteString]
exArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
seconds -> [ByteString
"EX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds]) Maybe Integer
hSetExSeconds
pxArg :: [ByteString]
pxArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
milliseconds -> [ByteString
"PX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds]) Maybe Integer
hSetExMilliseconds
exatArg :: [ByteString]
exatArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
seconds -> [ByteString
"EXAT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds]) Maybe Integer
hSetExUnixSeconds
pxatArg :: [ByteString]
pxatArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
milliseconds -> [ByteString
"PXAT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds]) Maybe Integer
hSetExUnixMilliseconds
keepTTLArg :: [ByteString]
keepTTLArg = [ByteString
"KEEPTTL" | Bool
hSetExKeepTTL]
data HashFieldExpirationStatus
= HashFieldExpirationNoSuchField
| HashFieldExpirationConditionNotMet
| HashFieldExpirationSet
| HashFieldExpirationDeleted
deriving (Int -> HashFieldExpirationStatus -> ShowS
[HashFieldExpirationStatus] -> ShowS
HashFieldExpirationStatus -> String
(Int -> HashFieldExpirationStatus -> ShowS)
-> (HashFieldExpirationStatus -> String)
-> ([HashFieldExpirationStatus] -> ShowS)
-> Show HashFieldExpirationStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HashFieldExpirationStatus -> ShowS
showsPrec :: Int -> HashFieldExpirationStatus -> ShowS
$cshow :: HashFieldExpirationStatus -> String
show :: HashFieldExpirationStatus -> String
$cshowList :: [HashFieldExpirationStatus] -> ShowS
showList :: [HashFieldExpirationStatus] -> ShowS
Show, HashFieldExpirationStatus -> HashFieldExpirationStatus -> Bool
(HashFieldExpirationStatus -> HashFieldExpirationStatus -> Bool)
-> (HashFieldExpirationStatus -> HashFieldExpirationStatus -> Bool)
-> Eq HashFieldExpirationStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HashFieldExpirationStatus -> HashFieldExpirationStatus -> Bool
== :: HashFieldExpirationStatus -> HashFieldExpirationStatus -> Bool
$c/= :: HashFieldExpirationStatus -> HashFieldExpirationStatus -> Bool
/= :: HashFieldExpirationStatus -> HashFieldExpirationStatus -> Bool
Eq)
instance RedisResult HashFieldExpirationStatus where
decode :: Reply -> Either Reply HashFieldExpirationStatus
decode Reply
r = do
value <- Reply -> Either Reply Integer
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
r :: Either Reply Integer
case value of
-2 -> HashFieldExpirationStatus -> Either Reply HashFieldExpirationStatus
forall a b. b -> Either a b
Right HashFieldExpirationStatus
HashFieldExpirationNoSuchField
Integer
0 -> HashFieldExpirationStatus -> Either Reply HashFieldExpirationStatus
forall a b. b -> Either a b
Right HashFieldExpirationStatus
HashFieldExpirationConditionNotMet
Integer
1 -> HashFieldExpirationStatus -> Either Reply HashFieldExpirationStatus
forall a b. b -> Either a b
Right HashFieldExpirationStatus
HashFieldExpirationSet
Integer
2 -> HashFieldExpirationStatus -> Either Reply HashFieldExpirationStatus
forall a b. b -> Either a b
Right HashFieldExpirationStatus
HashFieldExpirationDeleted
Integer
_ -> Reply -> Either Reply HashFieldExpirationStatus
forall a b. a -> Either a b
Left Reply
r
data HashFieldExpirationInfo
= HashFieldExpirationInfoNoSuchField
| HashFieldExpirationInfoNoExpiration
| HashFieldExpirationInfo Integer
deriving (Int -> HashFieldExpirationInfo -> ShowS
[HashFieldExpirationInfo] -> ShowS
HashFieldExpirationInfo -> String
(Int -> HashFieldExpirationInfo -> ShowS)
-> (HashFieldExpirationInfo -> String)
-> ([HashFieldExpirationInfo] -> ShowS)
-> Show HashFieldExpirationInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HashFieldExpirationInfo -> ShowS
showsPrec :: Int -> HashFieldExpirationInfo -> ShowS
$cshow :: HashFieldExpirationInfo -> String
show :: HashFieldExpirationInfo -> String
$cshowList :: [HashFieldExpirationInfo] -> ShowS
showList :: [HashFieldExpirationInfo] -> ShowS
Show, HashFieldExpirationInfo -> HashFieldExpirationInfo -> Bool
(HashFieldExpirationInfo -> HashFieldExpirationInfo -> Bool)
-> (HashFieldExpirationInfo -> HashFieldExpirationInfo -> Bool)
-> Eq HashFieldExpirationInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HashFieldExpirationInfo -> HashFieldExpirationInfo -> Bool
== :: HashFieldExpirationInfo -> HashFieldExpirationInfo -> Bool
$c/= :: HashFieldExpirationInfo -> HashFieldExpirationInfo -> Bool
/= :: HashFieldExpirationInfo -> HashFieldExpirationInfo -> Bool
Eq)
instance RedisResult HashFieldExpirationInfo where
decode :: Reply -> Either Reply HashFieldExpirationInfo
decode Reply
r = do
value <- Reply -> Either Reply Integer
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
r :: Either Reply Integer
case value of
-2 -> HashFieldExpirationInfo -> Either Reply HashFieldExpirationInfo
forall a b. b -> Either a b
Right HashFieldExpirationInfo
HashFieldExpirationInfoNoSuchField
-1 -> HashFieldExpirationInfo -> Either Reply HashFieldExpirationInfo
forall a b. b -> Either a b
Right HashFieldExpirationInfo
HashFieldExpirationInfoNoExpiration
Integer
n -> HashFieldExpirationInfo -> Either Reply HashFieldExpirationInfo
forall a b. b -> Either a b
Right (Integer -> HashFieldExpirationInfo
HashFieldExpirationInfo Integer
n)
hashFieldExpirationOptsToArgs :: ExpireOpts -> [ByteString]
hashFieldExpirationOptsToArgs :: ExpireOpts -> [ByteString]
hashFieldExpirationOptsToArgs ExpireOpts
opts =
[ExpireOpts -> ByteString
forall a. RedisArg a => a -> ByteString
encode ExpireOpts
opts]
hashFieldArgs :: NonEmpty ByteString -> [ByteString]
hashFieldArgs :: NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields =
[ByteString
"FIELDS", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty ByteString -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty ByteString
fields)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
fields
hexpire
:: (RedisCtx m f)
=> ByteString
-> Integer
-> NonEmpty ByteString
-> m (f [HashFieldExpirationStatus])
hexpire :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer
-> NonEmpty ByteString
-> m (f [HashFieldExpirationStatus])
hexpire ByteString
key Integer
seconds NonEmpty ByteString
fields =
[ByteString] -> m (f [HashFieldExpirationStatus])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationStatus]))
-> [ByteString] -> m (f [HashFieldExpirationStatus])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HEXPIRE", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
hexpireOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> NonEmpty ByteString
-> ExpireOpts
-> m (f [HashFieldExpirationStatus])
hexpireOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer
-> NonEmpty ByteString
-> ExpireOpts
-> m (f [HashFieldExpirationStatus])
hexpireOpts ByteString
key Integer
seconds NonEmpty ByteString
fields ExpireOpts
opts =
[ByteString] -> m (f [HashFieldExpirationStatus])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationStatus]))
-> [ByteString] -> m (f [HashFieldExpirationStatus])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HEXPIRE", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ExpireOpts -> [ByteString]
hashFieldExpirationOptsToArgs ExpireOpts
opts [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
hpexpire
:: (RedisCtx m f)
=> ByteString
-> Integer
-> NonEmpty ByteString
-> m (f [HashFieldExpirationStatus])
hpexpire :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer
-> NonEmpty ByteString
-> m (f [HashFieldExpirationStatus])
hpexpire ByteString
key Integer
milliseconds NonEmpty ByteString
fields =
[ByteString] -> m (f [HashFieldExpirationStatus])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationStatus]))
-> [ByteString] -> m (f [HashFieldExpirationStatus])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HPEXPIRE", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
hpexpireOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> NonEmpty ByteString
-> ExpireOpts
-> m (f [HashFieldExpirationStatus])
hpexpireOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer
-> NonEmpty ByteString
-> ExpireOpts
-> m (f [HashFieldExpirationStatus])
hpexpireOpts ByteString
key Integer
milliseconds NonEmpty ByteString
fields ExpireOpts
opts =
[ByteString] -> m (f [HashFieldExpirationStatus])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationStatus]))
-> [ByteString] -> m (f [HashFieldExpirationStatus])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HPEXPIRE", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ExpireOpts -> [ByteString]
hashFieldExpirationOptsToArgs ExpireOpts
opts [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
hexpireat
:: (RedisCtx m f)
=> ByteString
-> Integer
-> NonEmpty ByteString
-> m (f [HashFieldExpirationStatus])
hexpireat :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer
-> NonEmpty ByteString
-> m (f [HashFieldExpirationStatus])
hexpireat ByteString
key Integer
unixTimeSeconds NonEmpty ByteString
fields =
[ByteString] -> m (f [HashFieldExpirationStatus])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationStatus]))
-> [ByteString] -> m (f [HashFieldExpirationStatus])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HEXPIREAT", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
unixTimeSeconds] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
hexpireatOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> NonEmpty ByteString
-> ExpireOpts
-> m (f [HashFieldExpirationStatus])
hexpireatOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer
-> NonEmpty ByteString
-> ExpireOpts
-> m (f [HashFieldExpirationStatus])
hexpireatOpts ByteString
key Integer
unixTimeSeconds NonEmpty ByteString
fields ExpireOpts
opts =
[ByteString] -> m (f [HashFieldExpirationStatus])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationStatus]))
-> [ByteString] -> m (f [HashFieldExpirationStatus])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HEXPIREAT", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
unixTimeSeconds] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ExpireOpts -> [ByteString]
hashFieldExpirationOptsToArgs ExpireOpts
opts [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
hpexpireat
:: (RedisCtx m f)
=> ByteString
-> Integer
-> NonEmpty ByteString
-> m (f [HashFieldExpirationStatus])
hpexpireat :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer
-> NonEmpty ByteString
-> m (f [HashFieldExpirationStatus])
hpexpireat ByteString
key Integer
unixTimeMilliseconds NonEmpty ByteString
fields =
[ByteString] -> m (f [HashFieldExpirationStatus])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationStatus]))
-> [ByteString] -> m (f [HashFieldExpirationStatus])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HPEXPIREAT", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
unixTimeMilliseconds] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
hpexpireatOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> NonEmpty ByteString
-> ExpireOpts
-> m (f [HashFieldExpirationStatus])
hpexpireatOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer
-> NonEmpty ByteString
-> ExpireOpts
-> m (f [HashFieldExpirationStatus])
hpexpireatOpts ByteString
key Integer
unixTimeMilliseconds NonEmpty ByteString
fields ExpireOpts
opts =
[ByteString] -> m (f [HashFieldExpirationStatus])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationStatus]))
-> [ByteString] -> m (f [HashFieldExpirationStatus])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HPEXPIREAT", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
unixTimeMilliseconds] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ExpireOpts -> [ByteString]
hashFieldExpirationOptsToArgs ExpireOpts
opts [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
httl
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f [HashFieldExpirationInfo])
httl :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty ByteString -> m (f [HashFieldExpirationInfo])
httl ByteString
key NonEmpty ByteString
fields =
[ByteString] -> m (f [HashFieldExpirationInfo])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationInfo]))
-> [ByteString] -> m (f [HashFieldExpirationInfo])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HTTL", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
hpttl
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f [HashFieldExpirationInfo])
hpttl :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty ByteString -> m (f [HashFieldExpirationInfo])
hpttl ByteString
key NonEmpty ByteString
fields =
[ByteString] -> m (f [HashFieldExpirationInfo])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationInfo]))
-> [ByteString] -> m (f [HashFieldExpirationInfo])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HPTTL", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
hexpiretime
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f [HashFieldExpirationInfo])
hexpiretime :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty ByteString -> m (f [HashFieldExpirationInfo])
hexpiretime ByteString
key NonEmpty ByteString
fields =
[ByteString] -> m (f [HashFieldExpirationInfo])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationInfo]))
-> [ByteString] -> m (f [HashFieldExpirationInfo])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HEXPIRETIME", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
hpexpiretime
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f [HashFieldExpirationInfo])
hpexpiretime :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty ByteString -> m (f [HashFieldExpirationInfo])
hpexpiretime ByteString
key NonEmpty ByteString
fields =
[ByteString] -> m (f [HashFieldExpirationInfo])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [HashFieldExpirationInfo]))
-> [ByteString] -> m (f [HashFieldExpirationInfo])
forall a b. (a -> b) -> a -> b
$ [ByteString
"HPEXPIRETIME", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
hashFieldArgs NonEmpty ByteString
fields
data DebugMode = Yes | Sync | No deriving (Int -> DebugMode -> ShowS
[DebugMode] -> ShowS
DebugMode -> String
(Int -> DebugMode -> ShowS)
-> (DebugMode -> String)
-> ([DebugMode] -> ShowS)
-> Show DebugMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DebugMode -> ShowS
showsPrec :: Int -> DebugMode -> ShowS
$cshow :: DebugMode -> String
show :: DebugMode -> String
$cshowList :: [DebugMode] -> ShowS
showList :: [DebugMode] -> ShowS
Show, DebugMode -> DebugMode -> Bool
(DebugMode -> DebugMode -> Bool)
-> (DebugMode -> DebugMode -> Bool) -> Eq DebugMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DebugMode -> DebugMode -> Bool
== :: DebugMode -> DebugMode -> Bool
$c/= :: DebugMode -> DebugMode -> Bool
/= :: DebugMode -> DebugMode -> Bool
Eq)
instance RedisArg DebugMode where
encode :: DebugMode -> ByteString
encode DebugMode
Yes = ByteString
"YES"
encode DebugMode
Sync = ByteString
"SYNC"
encode DebugMode
No = ByteString
"NO"
scriptDebug
:: (RedisCtx m f)
=> DebugMode
-> m (f Bool)
scriptDebug :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
DebugMode -> m (f Bool)
scriptDebug DebugMode
mode =
[ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SCRIPT DEBUG", DebugMode -> ByteString
forall a. RedisArg a => a -> ByteString
encode DebugMode
mode]
zadd
:: (RedisCtx m f)
=> ByteString
-> [(Double,ByteString)]
-> m (f Integer)
zadd :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [(Double, ByteString)] -> m (f Integer)
zadd ByteString
key [(Double, ByteString)]
scoreMembers =
ByteString -> [(Double, ByteString)] -> ZaddOpts -> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [(Double, ByteString)] -> ZaddOpts -> m (f Integer)
zaddOpts ByteString
key [(Double, ByteString)]
scoreMembers ZaddOpts
defaultZaddOpts
data SizeCondition =
CGT |
CLT
deriving (Int -> SizeCondition -> ShowS
[SizeCondition] -> ShowS
SizeCondition -> String
(Int -> SizeCondition -> ShowS)
-> (SizeCondition -> String)
-> ([SizeCondition] -> ShowS)
-> Show SizeCondition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SizeCondition -> ShowS
showsPrec :: Int -> SizeCondition -> ShowS
$cshow :: SizeCondition -> String
show :: SizeCondition -> String
$cshowList :: [SizeCondition] -> ShowS
showList :: [SizeCondition] -> ShowS
Show, SizeCondition -> SizeCondition -> Bool
(SizeCondition -> SizeCondition -> Bool)
-> (SizeCondition -> SizeCondition -> Bool) -> Eq SizeCondition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SizeCondition -> SizeCondition -> Bool
== :: SizeCondition -> SizeCondition -> Bool
$c/= :: SizeCondition -> SizeCondition -> Bool
/= :: SizeCondition -> SizeCondition -> Bool
Eq)
instance RedisArg SizeCondition where
encode :: SizeCondition -> ByteString
encode SizeCondition
CGT = ByteString
"GT"
encode SizeCondition
CLT = ByteString
"LT"
data ZaddOpts = ZaddOpts
{ ZaddOpts -> Maybe Condition
zaddCondition :: Maybe Condition
, ZaddOpts -> Maybe SizeCondition
zaddSizeCondition :: Maybe SizeCondition
, ZaddOpts -> Bool
zaddChange :: Bool
, ZaddOpts -> Bool
zaddIncrement :: Bool
} deriving (Int -> ZaddOpts -> ShowS
[ZaddOpts] -> ShowS
ZaddOpts -> String
(Int -> ZaddOpts -> ShowS)
-> (ZaddOpts -> String) -> ([ZaddOpts] -> ShowS) -> Show ZaddOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ZaddOpts -> ShowS
showsPrec :: Int -> ZaddOpts -> ShowS
$cshow :: ZaddOpts -> String
show :: ZaddOpts -> String
$cshowList :: [ZaddOpts] -> ShowS
showList :: [ZaddOpts] -> ShowS
Show, ZaddOpts -> ZaddOpts -> Bool
(ZaddOpts -> ZaddOpts -> Bool)
-> (ZaddOpts -> ZaddOpts -> Bool) -> Eq ZaddOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ZaddOpts -> ZaddOpts -> Bool
== :: ZaddOpts -> ZaddOpts -> Bool
$c/= :: ZaddOpts -> ZaddOpts -> Bool
/= :: ZaddOpts -> ZaddOpts -> Bool
Eq)
defaultZaddOpts :: ZaddOpts
defaultZaddOpts :: ZaddOpts
defaultZaddOpts = ZaddOpts
{ zaddCondition :: Maybe Condition
zaddCondition = Maybe Condition
forall a. Maybe a
Nothing
, zaddChange :: Bool
zaddChange = Bool
False
, zaddIncrement :: Bool
zaddIncrement = Bool
False
, zaddSizeCondition :: Maybe SizeCondition
zaddSizeCondition = Maybe SizeCondition
forall a. Maybe a
Nothing
}
zaddOpts
:: (RedisCtx m f)
=> ByteString
-> [(Double,ByteString)]
-> ZaddOpts
-> m (f Integer)
zaddOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [(Double, ByteString)] -> ZaddOpts -> m (f Integer)
zaddOpts ByteString
key [(Double, ByteString)]
scoreMembers ZaddOpts{Bool
Maybe SizeCondition
Maybe Condition
zaddCondition :: ZaddOpts -> Maybe Condition
zaddSizeCondition :: ZaddOpts -> Maybe SizeCondition
zaddChange :: ZaddOpts -> Bool
zaddIncrement :: ZaddOpts -> Bool
zaddCondition :: Maybe Condition
zaddSizeCondition :: Maybe SizeCondition
zaddChange :: Bool
zaddIncrement :: Bool
..} =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [[ByteString]] -> [ByteString]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[ByteString
"ZADD", ByteString
key], [ByteString]
condition, [ByteString]
sizeCondition, [ByteString]
change, [ByteString]
increment, [ByteString]
scores]
where
scores :: [ByteString]
scores = ((Double, ByteString) -> [ByteString])
-> [(Double, ByteString)] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(Double
x,ByteString
y) -> [Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
x,ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
y]) [(Double, ByteString)]
scoreMembers
condition :: [ByteString]
condition = (Condition -> ByteString) -> [Condition] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Condition -> ByteString
forall a. RedisArg a => a -> ByteString
encode ([Condition] -> [ByteString]) -> [Condition] -> [ByteString]
forall a b. (a -> b) -> a -> b
$ Maybe Condition -> [Condition]
forall a. Maybe a -> [a]
maybeToList Maybe Condition
zaddCondition
sizeCondition :: [ByteString]
sizeCondition = (SizeCondition -> ByteString) -> [SizeCondition] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map SizeCondition -> ByteString
forall a. RedisArg a => a -> ByteString
encode ([SizeCondition] -> [ByteString])
-> [SizeCondition] -> [ByteString]
forall a b. (a -> b) -> a -> b
$ Maybe SizeCondition -> [SizeCondition]
forall a. Maybe a -> [a]
maybeToList Maybe SizeCondition
zaddSizeCondition
change :: [ByteString]
change = [ByteString
"CH" | Bool
zaddChange]
increment :: [ByteString]
increment = [ByteString
"INCR" | Bool
zaddIncrement]
data ReplyMode = On | Off | Skip deriving (Int -> ReplyMode -> ShowS
[ReplyMode] -> ShowS
ReplyMode -> String
(Int -> ReplyMode -> ShowS)
-> (ReplyMode -> String)
-> ([ReplyMode] -> ShowS)
-> Show ReplyMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReplyMode -> ShowS
showsPrec :: Int -> ReplyMode -> ShowS
$cshow :: ReplyMode -> String
show :: ReplyMode -> String
$cshowList :: [ReplyMode] -> ShowS
showList :: [ReplyMode] -> ShowS
Show, ReplyMode -> ReplyMode -> Bool
(ReplyMode -> ReplyMode -> Bool)
-> (ReplyMode -> ReplyMode -> Bool) -> Eq ReplyMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReplyMode -> ReplyMode -> Bool
== :: ReplyMode -> ReplyMode -> Bool
$c/= :: ReplyMode -> ReplyMode -> Bool
/= :: ReplyMode -> ReplyMode -> Bool
Eq)
instance RedisArg ReplyMode where
encode :: ReplyMode -> ByteString
encode ReplyMode
On = ByteString
"ON"
encode ReplyMode
Off = ByteString
"OFF"
encode ReplyMode
Skip = ByteString
"SKIP"
clientReply
:: (RedisCtx m f)
=> ReplyMode
-> m (f Bool)
clientReply :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ReplyMode -> m (f Bool)
clientReply ReplyMode
mode =
[ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLIENT REPLY", ReplyMode -> ByteString
forall a. RedisArg a => a -> ByteString
encode ReplyMode
mode]
clientUnpause
:: (RedisCtx m f)
=> m (f Status)
clientUnpause :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
clientUnpause = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLIENT", ByteString
"UNPAUSE"]
clientNoTouch
:: (RedisCtx m f)
=> Bool
-> m (f Status)
clientNoTouch :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Bool -> m (f Status)
clientNoTouch Bool
flag = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLIENT NO-TOUCH", ByteString
encodedFlag] where
encodedFlag :: ByteString
encodedFlag = if Bool
flag then ByteString
"ON" else ByteString
"OFF"
data ClientSetInfoOpts
= ClientSetInfoLibName ByteString
| ClientSetInfoLibVer ByteString
deriving (Int -> ClientSetInfoOpts -> ShowS
[ClientSetInfoOpts] -> ShowS
ClientSetInfoOpts -> String
(Int -> ClientSetInfoOpts -> ShowS)
-> (ClientSetInfoOpts -> String)
-> ([ClientSetInfoOpts] -> ShowS)
-> Show ClientSetInfoOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClientSetInfoOpts -> ShowS
showsPrec :: Int -> ClientSetInfoOpts -> ShowS
$cshow :: ClientSetInfoOpts -> String
show :: ClientSetInfoOpts -> String
$cshowList :: [ClientSetInfoOpts] -> ShowS
showList :: [ClientSetInfoOpts] -> ShowS
Show, ClientSetInfoOpts -> ClientSetInfoOpts -> Bool
(ClientSetInfoOpts -> ClientSetInfoOpts -> Bool)
-> (ClientSetInfoOpts -> ClientSetInfoOpts -> Bool)
-> Eq ClientSetInfoOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClientSetInfoOpts -> ClientSetInfoOpts -> Bool
== :: ClientSetInfoOpts -> ClientSetInfoOpts -> Bool
$c/= :: ClientSetInfoOpts -> ClientSetInfoOpts -> Bool
/= :: ClientSetInfoOpts -> ClientSetInfoOpts -> Bool
Eq)
clientSetinfo
:: (RedisCtx m f)
=> ClientSetInfoOpts
-> m (f Status)
clientSetinfo :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ClientSetInfoOpts -> m (f Status)
clientSetinfo ClientSetInfoOpts
info_ = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$ ByteString
"CLIENT"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
"SETINFO"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
clientSetInfoArg
where
clientSetInfoArg :: [ByteString]
clientSetInfoArg = case ClientSetInfoOpts
info_ of
ClientSetInfoLibName ByteString
s -> [ByteString
"LIB-NAME", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
s]
ClientSetInfoLibVer ByteString
s -> [ByteString
"LIB-VER", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
s]
srandmember
:: (RedisCtx m f)
=> ByteString
-> m (f (Maybe ByteString))
srandmember :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
srandmember ByteString
key = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SRANDMEMBER", ByteString
key]
srandmemberN
:: (RedisCtx m f)
=> ByteString
-> Integer
-> m (f [ByteString])
srandmemberN :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f [ByteString])
srandmemberN ByteString
key Integer
count = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SRANDMEMBER", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
spop
:: (RedisCtx m f)
=> ByteString
-> m (f (Maybe ByteString))
spop :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
spop ByteString
key = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SPOP", ByteString
key]
spopN
:: (RedisCtx m f)
=> ByteString
-> Integer
-> m (f [ByteString])
spopN :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f [ByteString])
spopN ByteString
key Integer
count = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SPOP", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
smismember
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f [Bool])
smismember :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f [Bool])
smismember ByteString
key (ByteString
member:|[ByteString]
members) = [ByteString] -> m (f [Bool])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"SMISMEMBER" ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
key ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
member ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
members)
data SintercardOpts = SintercardOpts
{ SintercardOpts -> Maybe Integer
sintercardLimit :: Maybe Integer
} deriving (Int -> SintercardOpts -> ShowS
[SintercardOpts] -> ShowS
SintercardOpts -> String
(Int -> SintercardOpts -> ShowS)
-> (SintercardOpts -> String)
-> ([SintercardOpts] -> ShowS)
-> Show SintercardOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SintercardOpts -> ShowS
showsPrec :: Int -> SintercardOpts -> ShowS
$cshow :: SintercardOpts -> String
show :: SintercardOpts -> String
$cshowList :: [SintercardOpts] -> ShowS
showList :: [SintercardOpts] -> ShowS
Show, SintercardOpts -> SintercardOpts -> Bool
(SintercardOpts -> SintercardOpts -> Bool)
-> (SintercardOpts -> SintercardOpts -> Bool) -> Eq SintercardOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SintercardOpts -> SintercardOpts -> Bool
== :: SintercardOpts -> SintercardOpts -> Bool
$c/= :: SintercardOpts -> SintercardOpts -> Bool
/= :: SintercardOpts -> SintercardOpts -> Bool
Eq)
defaultSintercardOpts :: SintercardOpts
defaultSintercardOpts :: SintercardOpts
defaultSintercardOpts = SintercardOpts
{ sintercardLimit :: Maybe Integer
sintercardLimit = Maybe Integer
forall a. Maybe a
Nothing
}
sintercard
:: (RedisCtx m f)
=> NonEmpty ByteString
-> m (f Integer)
sintercard :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> m (f Integer)
sintercard NonEmpty ByteString
keys = NonEmpty ByteString -> SintercardOpts -> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> SintercardOpts -> m (f Integer)
sintercardOpts NonEmpty ByteString
keys SintercardOpts
defaultSintercardOpts
sintercardOpts
:: (RedisCtx m f)
=> NonEmpty ByteString
-> SintercardOpts
-> m (f Integer)
sintercardOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> SintercardOpts -> m (f Integer)
sintercardOpts NonEmpty ByteString
keys SintercardOpts{Maybe Integer
sintercardLimit :: SintercardOpts -> Maybe Integer
sintercardLimit :: Maybe Integer
..} =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"SINTERCARD", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty ByteString -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty ByteString
keys)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
limitArg
where
limitArg :: [ByteString]
limitArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
limit -> [ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
limit]) Maybe Integer
sintercardLimit
info
:: (RedisCtx m f)
=> m (f ByteString)
info :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f ByteString)
info = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"INFO"]
infoSection
:: (RedisCtx m f)
=> ByteString
-> m (f ByteString)
infoSection :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ByteString)
infoSection ByteString
section = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"INFO", ByteString
section]
exists
:: (RedisCtx m f)
=> ByteString
-> m (f Bool)
exists :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Bool)
exists ByteString
key = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"EXISTS", ByteString
key]
newtype Cursor = Cursor ByteString deriving (Int -> Cursor -> ShowS
[Cursor] -> ShowS
Cursor -> String
(Int -> Cursor -> ShowS)
-> (Cursor -> String) -> ([Cursor] -> ShowS) -> Show Cursor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Cursor -> ShowS
showsPrec :: Int -> Cursor -> ShowS
$cshow :: Cursor -> String
show :: Cursor -> String
$cshowList :: [Cursor] -> ShowS
showList :: [Cursor] -> ShowS
Show, Cursor -> Cursor -> Bool
(Cursor -> Cursor -> Bool)
-> (Cursor -> Cursor -> Bool) -> Eq Cursor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Cursor -> Cursor -> Bool
== :: Cursor -> Cursor -> Bool
$c/= :: Cursor -> Cursor -> Bool
/= :: Cursor -> Cursor -> Bool
Eq)
instance RedisArg Cursor where
encode :: Cursor -> ByteString
encode (Cursor ByteString
c) = ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
c
instance RedisResult Cursor where
decode :: Reply -> Either Reply Cursor
decode (Bulk (Just ByteString
s)) = Cursor -> Either Reply Cursor
forall a b. b -> Either a b
Right (Cursor -> Either Reply Cursor) -> Cursor -> Either Reply Cursor
forall a b. (a -> b) -> a -> b
$ ByteString -> Cursor
Cursor ByteString
s
decode Reply
r = Reply -> Either Reply Cursor
forall a b. a -> Either a b
Left Reply
r
cursor0 :: Cursor
cursor0 :: Cursor
cursor0 = ByteString -> Cursor
Cursor ByteString
"0"
scan
:: (RedisCtx m f)
=> Cursor
-> m (f (Cursor, [ByteString]))
scan :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Cursor -> m (f (Cursor, [ByteString]))
scan Cursor
cursor = Cursor
-> ScanOpts -> Maybe ByteString -> m (f (Cursor, [ByteString]))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Cursor
-> ScanOpts -> Maybe ByteString -> m (f (Cursor, [ByteString]))
scanOpts Cursor
cursor ScanOpts
defaultScanOpts Maybe ByteString
forall a. Maybe a
Nothing
data ScanOpts = ScanOpts
{ ScanOpts -> Maybe ByteString
scanMatch :: Maybe ByteString
, ScanOpts -> Maybe Integer
scanCount :: Maybe Integer
} deriving (Int -> ScanOpts -> ShowS
[ScanOpts] -> ShowS
ScanOpts -> String
(Int -> ScanOpts -> ShowS)
-> (ScanOpts -> String) -> ([ScanOpts] -> ShowS) -> Show ScanOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScanOpts -> ShowS
showsPrec :: Int -> ScanOpts -> ShowS
$cshow :: ScanOpts -> String
show :: ScanOpts -> String
$cshowList :: [ScanOpts] -> ShowS
showList :: [ScanOpts] -> ShowS
Show, ScanOpts -> ScanOpts -> Bool
(ScanOpts -> ScanOpts -> Bool)
-> (ScanOpts -> ScanOpts -> Bool) -> Eq ScanOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScanOpts -> ScanOpts -> Bool
== :: ScanOpts -> ScanOpts -> Bool
$c/= :: ScanOpts -> ScanOpts -> Bool
/= :: ScanOpts -> ScanOpts -> Bool
Eq)
defaultScanOpts :: ScanOpts
defaultScanOpts :: ScanOpts
defaultScanOpts = ScanOpts
{ scanMatch :: Maybe ByteString
scanMatch = Maybe ByteString
forall a. Maybe a
Nothing
, scanCount :: Maybe Integer
scanCount = Maybe Integer
forall a. Maybe a
Nothing
}
scanOpts
:: (RedisCtx m f)
=> Cursor
-> ScanOpts
-> Maybe ByteString
-> m (f (Cursor, [ByteString]))
scanOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Cursor
-> ScanOpts -> Maybe ByteString -> m (f (Cursor, [ByteString]))
scanOpts Cursor
cursor ScanOpts
opts Maybe ByteString
mtype_ = [ByteString] -> m (f (Cursor, [ByteString]))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Cursor, [ByteString])))
-> [ByteString] -> m (f (Cursor, [ByteString]))
forall a b. (a -> b) -> a -> b
$ [ByteString] -> ScanOpts -> [ByteString]
addScanOpts [ByteString
"SCAN", Cursor -> ByteString
forall a. RedisArg a => a -> ByteString
encode Cursor
cursor] ScanOpts
opts
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\ByteString
type_ -> [ByteString
"TYPE", ByteString
type_]) Maybe ByteString
mtype_
addScanOpts
:: [ByteString]
-> ScanOpts
-> [ByteString]
addScanOpts :: [ByteString] -> ScanOpts -> [ByteString]
addScanOpts [ByteString]
cmd ScanOpts{Maybe Integer
Maybe ByteString
scanMatch :: ScanOpts -> Maybe ByteString
scanCount :: ScanOpts -> Maybe Integer
scanMatch :: Maybe ByteString
scanCount :: Maybe Integer
..} =
[[ByteString]] -> [ByteString]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[ByteString]
cmd, [ByteString]
match, [ByteString]
count]
where
prepend :: a -> a -> [a]
prepend a
x a
y = [a
x, a
y]
match :: [ByteString]
match = [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (ByteString -> ByteString -> [ByteString]
forall {a}. a -> a -> [a]
prepend ByteString
"MATCH") Maybe ByteString
scanMatch
count :: [ByteString]
count = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((ByteString -> ByteString -> [ByteString]
forall {a}. a -> a -> [a]
prepend ByteString
"COUNT")(ByteString -> [ByteString])
-> (Integer -> ByteString) -> Integer -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
.Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode) Maybe Integer
scanCount
sscan
:: (RedisCtx m f)
=> ByteString
-> Cursor
-> m (f (Cursor, [ByteString]))
sscan :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Cursor -> m (f (Cursor, [ByteString]))
sscan ByteString
key Cursor
cursor = ByteString -> Cursor -> ScanOpts -> m (f (Cursor, [ByteString]))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Cursor -> ScanOpts -> m (f (Cursor, [ByteString]))
sscanOpts ByteString
key Cursor
cursor ScanOpts
defaultScanOpts
sscanOpts
:: (RedisCtx m f)
=> ByteString
-> Cursor
-> ScanOpts
-> m (f (Cursor, [ByteString]))
sscanOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Cursor -> ScanOpts -> m (f (Cursor, [ByteString]))
sscanOpts ByteString
key Cursor
cursor ScanOpts
opts = [ByteString] -> m (f (Cursor, [ByteString]))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Cursor, [ByteString])))
-> [ByteString] -> m (f (Cursor, [ByteString]))
forall a b. (a -> b) -> a -> b
$ [ByteString] -> ScanOpts -> [ByteString]
addScanOpts [ByteString
"SSCAN", ByteString
key, Cursor -> ByteString
forall a. RedisArg a => a -> ByteString
encode Cursor
cursor] ScanOpts
opts
hscan
:: (RedisCtx m f)
=> ByteString
-> Cursor
-> m (f (Cursor, [(ByteString, ByteString)]))
hscan :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Cursor -> m (f (Cursor, [(ByteString, ByteString)]))
hscan ByteString
key Cursor
cursor = ByteString
-> Cursor -> ScanOpts -> m (f (Cursor, [(ByteString, ByteString)]))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Cursor -> ScanOpts -> m (f (Cursor, [(ByteString, ByteString)]))
hscanOpts ByteString
key Cursor
cursor ScanOpts
defaultScanOpts
hscanOpts
:: (RedisCtx m f)
=> ByteString
-> Cursor
-> ScanOpts
-> m (f (Cursor, [(ByteString, ByteString)]))
hscanOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Cursor -> ScanOpts -> m (f (Cursor, [(ByteString, ByteString)]))
hscanOpts ByteString
key Cursor
cursor ScanOpts
opts = [ByteString] -> m (f (Cursor, [(ByteString, ByteString)]))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Cursor, [(ByteString, ByteString)])))
-> [ByteString] -> m (f (Cursor, [(ByteString, ByteString)]))
forall a b. (a -> b) -> a -> b
$ [ByteString] -> ScanOpts -> [ByteString]
addScanOpts [ByteString
"HSCAN", ByteString
key, Cursor -> ByteString
forall a. RedisArg a => a -> ByteString
encode Cursor
cursor] ScanOpts
opts
hrandfield
:: (RedisCtx m f)
=> ByteString
-> m (f (Maybe ByteString))
hrandfield :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
hrandfield ByteString
key = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"HRANDFIELD", ByteString
key]
hrandfieldCount
:: (RedisCtx m f)
=> ByteString
-> Integer
-> m (f [ByteString])
hrandfieldCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f [ByteString])
hrandfieldCount ByteString
key Integer
count = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"HRANDFIELD", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
hrandfieldCountWithValues
:: (RedisCtx m f)
=> ByteString
-> Integer
-> m (f [(ByteString, ByteString)])
hrandfieldCountWithValues :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f [(ByteString, ByteString)])
hrandfieldCountWithValues ByteString
key Integer
count =
[ByteString] -> m (f [(ByteString, ByteString)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"HRANDFIELD", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count, ByteString
"WITHVALUES"]
zscan
:: (RedisCtx m f)
=> ByteString
-> Cursor
-> m (f (Cursor, [(ByteString, Double)]))
zscan :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Cursor -> m (f (Cursor, [(ByteString, Double)]))
zscan ByteString
key Cursor
cursor = ByteString
-> Cursor -> ScanOpts -> m (f (Cursor, [(ByteString, Double)]))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Cursor -> ScanOpts -> m (f (Cursor, [(ByteString, Double)]))
zscanOpts ByteString
key Cursor
cursor ScanOpts
defaultScanOpts
zscanOpts
:: (RedisCtx m f)
=> ByteString
-> Cursor
-> ScanOpts
-> m (f (Cursor, [(ByteString, Double)]))
zscanOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Cursor -> ScanOpts -> m (f (Cursor, [(ByteString, Double)]))
zscanOpts ByteString
key Cursor
cursor ScanOpts
opts = [ByteString] -> m (f (Cursor, [(ByteString, Double)]))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Cursor, [(ByteString, Double)])))
-> [ByteString] -> m (f (Cursor, [(ByteString, Double)]))
forall a b. (a -> b) -> a -> b
$ [ByteString] -> ScanOpts -> [ByteString]
addScanOpts [ByteString
"ZSCAN", ByteString
key, Cursor -> ByteString
forall a. RedisArg a => a -> ByteString
encode Cursor
cursor] ScanOpts
opts
data RangeLex a = Incl a | Excl a | Minr | Maxr deriving (Int -> RangeLex a -> ShowS
[RangeLex a] -> ShowS
RangeLex a -> String
(Int -> RangeLex a -> ShowS)
-> (RangeLex a -> String)
-> ([RangeLex a] -> ShowS)
-> Show (RangeLex a)
forall a. Show a => Int -> RangeLex a -> ShowS
forall a. Show a => [RangeLex a] -> ShowS
forall a. Show a => RangeLex a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> RangeLex a -> ShowS
showsPrec :: Int -> RangeLex a -> ShowS
$cshow :: forall a. Show a => RangeLex a -> String
show :: RangeLex a -> String
$cshowList :: forall a. Show a => [RangeLex a] -> ShowS
showList :: [RangeLex a] -> ShowS
Show, RangeLex a -> RangeLex a -> Bool
(RangeLex a -> RangeLex a -> Bool)
-> (RangeLex a -> RangeLex a -> Bool) -> Eq (RangeLex a)
forall a. Eq a => RangeLex a -> RangeLex a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => RangeLex a -> RangeLex a -> Bool
== :: RangeLex a -> RangeLex a -> Bool
$c/= :: forall a. Eq a => RangeLex a -> RangeLex a -> Bool
/= :: RangeLex a -> RangeLex a -> Bool
Eq)
instance RedisArg a => RedisArg (RangeLex a) where
encode :: RangeLex a -> ByteString
encode (Incl a
bs) = ByteString
"[" ByteString -> ByteString -> ByteString
`append` a -> ByteString
forall a. RedisArg a => a -> ByteString
encode a
bs
encode (Excl a
bs) = ByteString
"(" ByteString -> ByteString -> ByteString
`append` a -> ByteString
forall a. RedisArg a => a -> ByteString
encode a
bs
encode RangeLex a
Minr = ByteString
"-"
encode RangeLex a
Maxr = ByteString
"+"
zrangebylex::(RedisCtx m f) =>
ByteString
-> RangeLex ByteString
-> RangeLex ByteString
-> m (f [ByteString])
zrangebylex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> RangeLex ByteString -> RangeLex ByteString -> m (f [ByteString])
zrangebylex ByteString
key RangeLex ByteString
min RangeLex ByteString
max =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANGEBYLEX", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key, RangeLex ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode RangeLex ByteString
min, RangeLex ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode RangeLex ByteString
max]
zrangebylexLimit
::(RedisCtx m f)
=> ByteString
-> RangeLex ByteString
-> RangeLex ByteString
-> Integer
-> Integer
-> m (f [ByteString])
zrangebylexLimit :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> RangeLex ByteString
-> RangeLex ByteString
-> Integer
-> Integer
-> m (f [ByteString])
zrangebylexLimit ByteString
key RangeLex ByteString
min RangeLex ByteString
max Integer
offset Integer
count =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANGEBYLEX", ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode ByteString
key, RangeLex ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode RangeLex ByteString
min, RangeLex ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode RangeLex ByteString
max,
ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
offset, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
data ZPopMinMax = ZPopMin | ZPopMax deriving (Int -> ZPopMinMax -> ShowS
[ZPopMinMax] -> ShowS
ZPopMinMax -> String
(Int -> ZPopMinMax -> ShowS)
-> (ZPopMinMax -> String)
-> ([ZPopMinMax] -> ShowS)
-> Show ZPopMinMax
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ZPopMinMax -> ShowS
showsPrec :: Int -> ZPopMinMax -> ShowS
$cshow :: ZPopMinMax -> String
show :: ZPopMinMax -> String
$cshowList :: [ZPopMinMax] -> ShowS
showList :: [ZPopMinMax] -> ShowS
Show, ZPopMinMax -> ZPopMinMax -> Bool
(ZPopMinMax -> ZPopMinMax -> Bool)
-> (ZPopMinMax -> ZPopMinMax -> Bool) -> Eq ZPopMinMax
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ZPopMinMax -> ZPopMinMax -> Bool
== :: ZPopMinMax -> ZPopMinMax -> Bool
$c/= :: ZPopMinMax -> ZPopMinMax -> Bool
/= :: ZPopMinMax -> ZPopMinMax -> Bool
Eq)
instance RedisArg ZPopMinMax where
encode :: ZPopMinMax -> ByteString
encode ZPopMinMax
ZPopMin = ByteString
"MIN"
encode ZPopMinMax
ZPopMax = ByteString
"MAX"
data ZPopResponse = ZPopResponse
{ ZPopResponse -> Maybe ByteString
zPopResponseKey :: Maybe ByteString
, ZPopResponse -> [(ByteString, Double)]
zPopResponseValues :: [(ByteString, Double)]
} deriving (Int -> ZPopResponse -> ShowS
[ZPopResponse] -> ShowS
ZPopResponse -> String
(Int -> ZPopResponse -> ShowS)
-> (ZPopResponse -> String)
-> ([ZPopResponse] -> ShowS)
-> Show ZPopResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ZPopResponse -> ShowS
showsPrec :: Int -> ZPopResponse -> ShowS
$cshow :: ZPopResponse -> String
show :: ZPopResponse -> String
$cshowList :: [ZPopResponse] -> ShowS
showList :: [ZPopResponse] -> ShowS
Show, ZPopResponse -> ZPopResponse -> Bool
(ZPopResponse -> ZPopResponse -> Bool)
-> (ZPopResponse -> ZPopResponse -> Bool) -> Eq ZPopResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ZPopResponse -> ZPopResponse -> Bool
== :: ZPopResponse -> ZPopResponse -> Bool
$c/= :: ZPopResponse -> ZPopResponse -> Bool
/= :: ZPopResponse -> ZPopResponse -> Bool
Eq)
instance RedisResult ZPopResponse where
decode :: Reply -> Either Reply ZPopResponse
decode (MultiBulk (Just [Bulk (Just ByteString
key), MultiBulk (Just [Reply]
values)])) =
Maybe ByteString -> [(ByteString, Double)] -> ZPopResponse
ZPopResponse (ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
key) ([(ByteString, Double)] -> ZPopResponse)
-> Either Reply [(ByteString, Double)] -> Either Reply ZPopResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Reply -> Either Reply (ByteString, Double))
-> [Reply] -> Either Reply [(ByteString, Double)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply (ByteString, Double)
forall a. RedisResult a => Reply -> Either Reply a
decode [Reply]
values
decode Reply
r = Reply -> Either Reply ZPopResponse
forall a b. a -> Either a b
Left Reply
r
zmpop
:: (RedisCtx m f)
=> NonEmpty ByteString
-> ZPopMinMax
-> m (f (Maybe ZPopResponse))
zmpop :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString -> ZPopMinMax -> m (f (Maybe ZPopResponse))
zmpop NonEmpty ByteString
keys ZPopMinMax
where_ = NonEmpty ByteString
-> ZPopMinMax -> Integer -> m (f (Maybe ZPopResponse))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> ZPopMinMax -> Integer -> m (f (Maybe ZPopResponse))
zmpopCount NonEmpty ByteString
keys ZPopMinMax
where_ Integer
1
zmpopCount
:: (RedisCtx m f)
=> NonEmpty ByteString
-> ZPopMinMax
-> Integer
-> m (f (Maybe ZPopResponse))
zmpopCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty ByteString
-> ZPopMinMax -> Integer -> m (f (Maybe ZPopResponse))
zmpopCount NonEmpty ByteString
keys ZPopMinMax
where_ Integer
count =
[ByteString] -> m (f (Maybe ZPopResponse))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe ZPopResponse)))
-> [ByteString] -> m (f (Maybe ZPopResponse))
forall a b. (a -> b) -> a -> b
$ [ByteString
"ZMPOP", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty ByteString -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty ByteString
keys)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ZPopMinMax -> ByteString
forall a. RedisArg a => a -> ByteString
encode ZPopMinMax
where_, ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
bzmpop
:: (RedisCtx m f)
=> Double
-> NonEmpty ByteString
-> ZPopMinMax
-> m (f (Maybe ZPopResponse))
bzmpop :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Double
-> NonEmpty ByteString -> ZPopMinMax -> m (f (Maybe ZPopResponse))
bzmpop Double
timeout NonEmpty ByteString
keys ZPopMinMax
where_ = Double
-> NonEmpty ByteString
-> ZPopMinMax
-> Integer
-> m (f (Maybe ZPopResponse))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Double
-> NonEmpty ByteString
-> ZPopMinMax
-> Integer
-> m (f (Maybe ZPopResponse))
bzmpopCount Double
timeout NonEmpty ByteString
keys ZPopMinMax
where_ Integer
1
bzmpopCount
:: (RedisCtx m f)
=> Double
-> NonEmpty ByteString
-> ZPopMinMax
-> Integer
-> m (f (Maybe ZPopResponse))
bzmpopCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Double
-> NonEmpty ByteString
-> ZPopMinMax
-> Integer
-> m (f (Maybe ZPopResponse))
bzmpopCount Double
timeout NonEmpty ByteString
keys ZPopMinMax
where_ Integer
count =
[ByteString] -> m (f (Maybe ZPopResponse))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe ZPopResponse)))
-> [ByteString] -> m (f (Maybe ZPopResponse))
forall a b. (a -> b) -> a -> b
$ [ByteString
"BZMPOP", Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
timeout, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty ByteString -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty ByteString
keys)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
keys [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ZPopMinMax -> ByteString
forall a. RedisArg a => a -> ByteString
encode ZPopMinMax
where_, ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
zmscore
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f [Maybe Double])
zmscore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f [Maybe Double])
zmscore ByteString
key (ByteString
member:|[ByteString]
members) = [ByteString] -> m (f [Maybe Double])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"ZMSCORE" ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
key ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
member ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
members)
zrandmember
:: (RedisCtx m f)
=> ByteString
-> m (f (Maybe ByteString))
zrandmember :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe ByteString))
zrandmember ByteString
key = [ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANDMEMBER", ByteString
key]
zrandmemberN
:: (RedisCtx m f)
=> ByteString
-> Integer
-> m (f [ByteString])
zrandmemberN :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f [ByteString])
zrandmemberN ByteString
key Integer
count = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANDMEMBER", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]
zrandmemberWithscores
:: (RedisCtx m f)
=> ByteString
-> Integer
-> m (f [(ByteString, Double)])
zrandmemberWithscores :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f [(ByteString, Double)])
zrandmemberWithscores ByteString
key Integer
count =
[ByteString] -> m (f [(ByteString, Double)])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ZRANDMEMBER", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count, ByteString
"WITHSCORES"]
data ZRangeStoreRange
= ZRangeStoreByIndex Integer Integer
| ZRangeStoreByScore Double Double
| ZRangeStoreByLex (RangeLex ByteString) (RangeLex ByteString)
deriving (Int -> ZRangeStoreRange -> ShowS
[ZRangeStoreRange] -> ShowS
ZRangeStoreRange -> String
(Int -> ZRangeStoreRange -> ShowS)
-> (ZRangeStoreRange -> String)
-> ([ZRangeStoreRange] -> ShowS)
-> Show ZRangeStoreRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ZRangeStoreRange -> ShowS
showsPrec :: Int -> ZRangeStoreRange -> ShowS
$cshow :: ZRangeStoreRange -> String
show :: ZRangeStoreRange -> String
$cshowList :: [ZRangeStoreRange] -> ShowS
showList :: [ZRangeStoreRange] -> ShowS
Show, ZRangeStoreRange -> ZRangeStoreRange -> Bool
(ZRangeStoreRange -> ZRangeStoreRange -> Bool)
-> (ZRangeStoreRange -> ZRangeStoreRange -> Bool)
-> Eq ZRangeStoreRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ZRangeStoreRange -> ZRangeStoreRange -> Bool
== :: ZRangeStoreRange -> ZRangeStoreRange -> Bool
$c/= :: ZRangeStoreRange -> ZRangeStoreRange -> Bool
/= :: ZRangeStoreRange -> ZRangeStoreRange -> Bool
Eq)
data ZRangeStoreOpts = ZRangeStoreOpts
{ ZRangeStoreOpts -> Bool
zRangeStoreRev :: Bool
, ZRangeStoreOpts -> Maybe (Integer, Integer)
zRangeStoreLimit :: Maybe (Integer, Integer)
} deriving (Int -> ZRangeStoreOpts -> ShowS
[ZRangeStoreOpts] -> ShowS
ZRangeStoreOpts -> String
(Int -> ZRangeStoreOpts -> ShowS)
-> (ZRangeStoreOpts -> String)
-> ([ZRangeStoreOpts] -> ShowS)
-> Show ZRangeStoreOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ZRangeStoreOpts -> ShowS
showsPrec :: Int -> ZRangeStoreOpts -> ShowS
$cshow :: ZRangeStoreOpts -> String
show :: ZRangeStoreOpts -> String
$cshowList :: [ZRangeStoreOpts] -> ShowS
showList :: [ZRangeStoreOpts] -> ShowS
Show, ZRangeStoreOpts -> ZRangeStoreOpts -> Bool
(ZRangeStoreOpts -> ZRangeStoreOpts -> Bool)
-> (ZRangeStoreOpts -> ZRangeStoreOpts -> Bool)
-> Eq ZRangeStoreOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ZRangeStoreOpts -> ZRangeStoreOpts -> Bool
== :: ZRangeStoreOpts -> ZRangeStoreOpts -> Bool
$c/= :: ZRangeStoreOpts -> ZRangeStoreOpts -> Bool
/= :: ZRangeStoreOpts -> ZRangeStoreOpts -> Bool
Eq)
defaultZRangeStoreOpts :: ZRangeStoreOpts
defaultZRangeStoreOpts :: ZRangeStoreOpts
defaultZRangeStoreOpts = ZRangeStoreOpts
{ zRangeStoreRev :: Bool
zRangeStoreRev = Bool
False
, zRangeStoreLimit :: Maybe (Integer, Integer)
zRangeStoreLimit = Maybe (Integer, Integer)
forall a. Maybe a
Nothing
}
zrangestore
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> Integer
-> Integer
-> m (f Integer)
zrangestore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> Integer -> Integer -> m (f Integer)
zrangestore ByteString
destination ByteString
source Integer
start Integer
stop =
ByteString
-> ByteString
-> ZRangeStoreRange
-> ZRangeStoreOpts
-> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ZRangeStoreRange
-> ZRangeStoreOpts
-> m (f Integer)
zrangestoreOpts ByteString
destination ByteString
source (Integer -> Integer -> ZRangeStoreRange
ZRangeStoreByIndex Integer
start Integer
stop) ZRangeStoreOpts
defaultZRangeStoreOpts
zrangestoreOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ZRangeStoreRange
-> ZRangeStoreOpts
-> m (f Integer)
zrangestoreOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ZRangeStoreRange
-> ZRangeStoreOpts
-> m (f Integer)
zrangestoreOpts ByteString
destination ByteString
source ZRangeStoreRange
range ZRangeStoreOpts
opts =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"ZRANGESTORE", ByteString
destination, ByteString
source] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ZRangeStoreRange -> [ByteString]
zRangeStoreRangeArgs ZRangeStoreRange
range [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ZRangeStoreOpts -> [ByteString]
zRangeStoreOptsArgs ZRangeStoreOpts
opts
zRangeStoreRangeArgs :: ZRangeStoreRange -> [ByteString]
zRangeStoreRangeArgs :: ZRangeStoreRange -> [ByteString]
zRangeStoreRangeArgs ZRangeStoreRange
range = case ZRangeStoreRange
range of
ZRangeStoreByIndex Integer
start Integer
stop ->
[Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
stop]
ZRangeStoreByScore Double
minScore Double
maxScore ->
[Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
minScore, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
maxScore, ByteString
"BYSCORE"]
ZRangeStoreByLex RangeLex ByteString
minMember RangeLex ByteString
maxMember ->
[RangeLex ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode RangeLex ByteString
minMember, RangeLex ByteString -> ByteString
forall a. RedisArg a => a -> ByteString
encode RangeLex ByteString
maxMember, ByteString
"BYLEX"]
zRangeStoreOptsArgs :: ZRangeStoreOpts -> [ByteString]
zRangeStoreOptsArgs :: ZRangeStoreOpts -> [ByteString]
zRangeStoreOptsArgs ZRangeStoreOpts{Bool
Maybe (Integer, Integer)
zRangeStoreRev :: ZRangeStoreOpts -> Bool
zRangeStoreLimit :: ZRangeStoreOpts -> Maybe (Integer, Integer)
zRangeStoreRev :: Bool
zRangeStoreLimit :: Maybe (Integer, Integer)
..} =
[ByteString]
revArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
limitArg
where
revArg :: [ByteString]
revArg = [ByteString
"REV" | Bool
zRangeStoreRev]
limitArg :: [ByteString]
limitArg = [ByteString]
-> ((Integer, Integer) -> [ByteString])
-> Maybe (Integer, Integer)
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\(Integer
offset, Integer
count) -> [ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
offset, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]) Maybe (Integer, Integer)
zRangeStoreLimit
data TrimStrategy
= TrimMaxlen Integer
| TrimMinId ByteString
data TrimType
= TrimExact
| TrimApprox (Maybe Integer)
data TrimOpts = TrimOpts
{ TrimOpts -> TrimStrategy
trimOptsStrategy :: TrimStrategy
, TrimOpts -> TrimType
trimOptsType :: TrimType
}
internalTrimArgToList :: TrimOpts -> [ByteString]
internalTrimArgToList :: TrimOpts -> [ByteString]
internalTrimArgToList TrimOpts{TrimType
TrimStrategy
trimOptsStrategy :: TrimOpts -> TrimStrategy
trimOptsType :: TrimOpts -> TrimType
trimOptsStrategy :: TrimStrategy
trimOptsType :: TrimType
..} = [ByteString]
trimArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
limitArg
where trimArg :: [ByteString]
trimArg = case TrimStrategy
trimOptsStrategy of
TrimMaxlen Integer
max -> (ByteString
"MAXLEN"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
approxArgByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
maxByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[])
TrimMinId ByteString
i -> (ByteString
"MINID"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
approxArgByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
iByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[])
(ByteString
approxArg, [ByteString]
limitArg) = case TrimType
trimOptsType of
TrimType
TrimExact -> (ByteString
"=", [])
TrimApprox Maybe Integer
limit -> (ByteString
"~", [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((ByteString
"LIMIT"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:) ([ByteString] -> [ByteString])
-> (Integer -> [ByteString]) -> Integer -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[]) (ByteString -> [ByteString])
-> (Integer -> ByteString) -> Integer -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode) Maybe Integer
limit)
trimOpts :: TrimStrategy -> TrimType -> TrimOpts
trimOpts :: TrimStrategy -> TrimType -> TrimOpts
trimOpts = TrimStrategy -> TrimType -> TrimOpts
TrimOpts
data XAddOpts = XAddOpts {
XAddOpts -> Maybe TrimOpts
xAddTrimOpts :: Maybe TrimOpts,
XAddOpts -> Bool
xAddnoMkStream :: Bool
}
defaultXAddOpts :: XAddOpts
defaultXAddOpts :: XAddOpts
defaultXAddOpts = XAddOpts {
xAddTrimOpts :: Maybe TrimOpts
xAddTrimOpts = Maybe TrimOpts
forall a. Maybe a
Nothing,
xAddnoMkStream :: Bool
xAddnoMkStream = Bool
False
}
xaddOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> XAddOpts
-> m (f ByteString)
xaddOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> XAddOpts
-> m (f ByteString)
xaddOpts ByteString
key ByteString
entryId [(ByteString, ByteString)]
fieldValues XAddOpts
opts = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f ByteString))
-> [ByteString] -> m (f ByteString)
forall a b. (a -> b) -> a -> b
$
[ByteString
"XADD", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
noMkStreamArgs [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
trimArgs [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
entryId] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
fieldArgs
where
fieldArgs :: [ByteString]
fieldArgs = ((ByteString, ByteString) -> [ByteString])
-> [(ByteString, ByteString)] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(ByteString
x,ByteString
y) -> [ByteString
x,ByteString
y]) [(ByteString, ByteString)]
fieldValues
noMkStreamArgs :: [ByteString]
noMkStreamArgs = [ByteString
"NOMKSTREAM" | XAddOpts -> Bool
xAddnoMkStream XAddOpts
opts]
trimArgs :: [ByteString]
trimArgs = [ByteString]
-> (TrimOpts -> [ByteString]) -> Maybe TrimOpts -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (TrimOpts -> [ByteString]
internalTrimArgToList) (XAddOpts -> Maybe TrimOpts
xAddTrimOpts XAddOpts
opts)
xadd
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> m (f ByteString)
xadd :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> [(ByteString, ByteString)] -> m (f ByteString)
xadd ByteString
key ByteString
entryId [(ByteString, ByteString)]
fieldValues = ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> XAddOpts
-> m (f ByteString)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> XAddOpts
-> m (f ByteString)
xaddOpts ByteString
key ByteString
entryId [(ByteString, ByteString)]
fieldValues XAddOpts
defaultXAddOpts
newtype XAutoclaimOpts = XAutoclaimOpts {
XAutoclaimOpts -> Maybe Integer
xAutoclaimCount :: Maybe Integer
}
defaultXAutoclaimOpts :: XAutoclaimOpts
defaultXAutoclaimOpts :: XAutoclaimOpts
defaultXAutoclaimOpts = XAutoclaimOpts {
xAutoclaimCount :: Maybe Integer
xAutoclaimCount = Maybe Integer
forall a. Maybe a
Nothing
}
data XAutoclaimResult resultFormat = XAutoclaimResult {
forall resultFormat. XAutoclaimResult resultFormat -> ByteString
xAutoclaimResultId :: ByteString,
forall resultFormat.
XAutoclaimResult resultFormat -> [resultFormat]
xAutoclaimClaimedMessages :: [resultFormat],
forall resultFormat. XAutoclaimResult resultFormat -> [ByteString]
xAutoclaimDeletedMessages :: [ByteString]
} deriving (Int -> XAutoclaimResult resultFormat -> ShowS
[XAutoclaimResult resultFormat] -> ShowS
XAutoclaimResult resultFormat -> String
(Int -> XAutoclaimResult resultFormat -> ShowS)
-> (XAutoclaimResult resultFormat -> String)
-> ([XAutoclaimResult resultFormat] -> ShowS)
-> Show (XAutoclaimResult resultFormat)
forall resultFormat.
Show resultFormat =>
Int -> XAutoclaimResult resultFormat -> ShowS
forall resultFormat.
Show resultFormat =>
[XAutoclaimResult resultFormat] -> ShowS
forall resultFormat.
Show resultFormat =>
XAutoclaimResult resultFormat -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall resultFormat.
Show resultFormat =>
Int -> XAutoclaimResult resultFormat -> ShowS
showsPrec :: Int -> XAutoclaimResult resultFormat -> ShowS
$cshow :: forall resultFormat.
Show resultFormat =>
XAutoclaimResult resultFormat -> String
show :: XAutoclaimResult resultFormat -> String
$cshowList :: forall resultFormat.
Show resultFormat =>
[XAutoclaimResult resultFormat] -> ShowS
showList :: [XAutoclaimResult resultFormat] -> ShowS
Show, XAutoclaimResult resultFormat
-> XAutoclaimResult resultFormat -> Bool
(XAutoclaimResult resultFormat
-> XAutoclaimResult resultFormat -> Bool)
-> (XAutoclaimResult resultFormat
-> XAutoclaimResult resultFormat -> Bool)
-> Eq (XAutoclaimResult resultFormat)
forall resultFormat.
Eq resultFormat =>
XAutoclaimResult resultFormat
-> XAutoclaimResult resultFormat -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall resultFormat.
Eq resultFormat =>
XAutoclaimResult resultFormat
-> XAutoclaimResult resultFormat -> Bool
== :: XAutoclaimResult resultFormat
-> XAutoclaimResult resultFormat -> Bool
$c/= :: forall resultFormat.
Eq resultFormat =>
XAutoclaimResult resultFormat
-> XAutoclaimResult resultFormat -> Bool
/= :: XAutoclaimResult resultFormat
-> XAutoclaimResult resultFormat -> Bool
Eq)
instance RedisResult a => RedisResult (XAutoclaimResult a) where
decode :: Reply -> Either Reply (XAutoclaimResult a)
decode (MultiBulk (Just [
Bulk (Just ByteString
xAutoclaimResultId) ,
Reply
claimedMsg,
Reply
deletedMsg])) = do
xAutoclaimClaimedMessages <- Reply -> Either Reply [a]
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
claimedMsg
xAutoclaimDeletedMessages <- decode deletedMsg
Right XAutoclaimResult{..}
decode (MultiBulk (Just [
Bulk (Just ByteString
xAutoclaimResultId) ,
MultiBulk (Just [])
])) = do
let xAutoclaimClaimedMessages :: [a]
xAutoclaimClaimedMessages = []
let xAutoclaimDeletedMessages :: [a]
xAutoclaimDeletedMessages = []
XAutoclaimResult a -> Either Reply (XAutoclaimResult a)
forall a b. b -> Either a b
Right XAutoclaimResult{[a]
[ByteString]
ByteString
forall a. [a]
xAutoclaimResultId :: ByteString
xAutoclaimClaimedMessages :: [a]
xAutoclaimDeletedMessages :: [ByteString]
xAutoclaimResultId :: ByteString
xAutoclaimClaimedMessages :: forall a. [a]
xAutoclaimDeletedMessages :: forall a. [a]
..}
decode Reply
a = Reply -> Either Reply (XAutoclaimResult a)
forall a b. a -> Either a b
Left Reply
a
type XAutoclaimStreamsResult = XAutoclaimResult StreamsRecord
type XAutoclaimJustIdsResult = XAutoclaimResult ByteString
xautoclaim
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> m (f XAutoclaimStreamsResult)
xautoclaim :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> m (f XAutoclaimStreamsResult)
xautoclaim ByteString
key ByteString
group ByteString
consumer Integer
min_idle_time ByteString
start = ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> XAutoclaimOpts
-> m (f XAutoclaimStreamsResult)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> XAutoclaimOpts
-> m (f XAutoclaimStreamsResult)
xautoclaimOpts ByteString
key ByteString
group ByteString
consumer Integer
min_idle_time ByteString
start XAutoclaimOpts
defaultXAutoclaimOpts
xautoclaimOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> XAutoclaimOpts
-> m (f XAutoclaimStreamsResult)
xautoclaimOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> XAutoclaimOpts
-> m (f XAutoclaimStreamsResult)
xautoclaimOpts ByteString
key ByteString
group ByteString
consumer Integer
min_idle_time ByteString
start XAutoclaimOpts
opts = [ByteString] -> m (f XAutoclaimStreamsResult)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f XAutoclaimStreamsResult))
-> [ByteString] -> m (f XAutoclaimStreamsResult)
forall a b. (a -> b) -> a -> b
$
[ByteString
"XAUTOCLAIM", ByteString
key, ByteString
group, ByteString
consumer, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
min_idle_time, ByteString
start] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
count
where count :: [ByteString]
count = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((ByteString
"COUNT"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:) ([ByteString] -> [ByteString])
-> (Integer -> [ByteString]) -> Integer -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[]) (ByteString -> [ByteString])
-> (Integer -> ByteString) -> Integer -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode) (XAutoclaimOpts -> Maybe Integer
xAutoclaimCount XAutoclaimOpts
opts)
xautoclaimJustIds
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> m (f XAutoclaimJustIdsResult)
xautoclaimJustIds :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> m (f XAutoclaimJustIdsResult)
xautoclaimJustIds ByteString
key ByteString
group ByteString
consumer Integer
min_idle_time ByteString
start =
ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> XAutoclaimOpts
-> m (f XAutoclaimJustIdsResult)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> XAutoclaimOpts
-> m (f XAutoclaimJustIdsResult)
xautoclaimJustIdsOpts ByteString
key ByteString
group ByteString
consumer Integer
min_idle_time ByteString
start XAutoclaimOpts
defaultXAutoclaimOpts
xautoclaimJustIdsOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> XAutoclaimOpts
-> m (f XAutoclaimJustIdsResult)
xautoclaimJustIdsOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Integer
-> ByteString
-> XAutoclaimOpts
-> m (f XAutoclaimJustIdsResult)
xautoclaimJustIdsOpts ByteString
key ByteString
group ByteString
consumer Integer
min_idle_time ByteString
start XAutoclaimOpts
opts = [ByteString] -> m (f XAutoclaimJustIdsResult)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f XAutoclaimJustIdsResult))
-> [ByteString] -> m (f XAutoclaimJustIdsResult)
forall a b. (a -> b) -> a -> b
$
[ByteString
"XAUTOCLAIM", ByteString
key, ByteString
group, ByteString
consumer, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
min_idle_time, ByteString
start] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
count [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"JUSTID"]
where count :: [ByteString]
count = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((ByteString
"COUNT"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:) ([ByteString] -> [ByteString])
-> (Integer -> [ByteString]) -> Integer -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[]) (ByteString -> [ByteString])
-> (Integer -> ByteString) -> Integer -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode) (XAutoclaimOpts -> Maybe Integer
xAutoclaimCount XAutoclaimOpts
opts)
data StreamsRecord = StreamsRecord
{ StreamsRecord -> ByteString
recordId :: ByteString
, StreamsRecord -> [(ByteString, ByteString)]
keyValues :: [(ByteString, ByteString)]
} deriving (Int -> StreamsRecord -> ShowS
[StreamsRecord] -> ShowS
StreamsRecord -> String
(Int -> StreamsRecord -> ShowS)
-> (StreamsRecord -> String)
-> ([StreamsRecord] -> ShowS)
-> Show StreamsRecord
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StreamsRecord -> ShowS
showsPrec :: Int -> StreamsRecord -> ShowS
$cshow :: StreamsRecord -> String
show :: StreamsRecord -> String
$cshowList :: [StreamsRecord] -> ShowS
showList :: [StreamsRecord] -> ShowS
Show, StreamsRecord -> StreamsRecord -> Bool
(StreamsRecord -> StreamsRecord -> Bool)
-> (StreamsRecord -> StreamsRecord -> Bool) -> Eq StreamsRecord
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StreamsRecord -> StreamsRecord -> Bool
== :: StreamsRecord -> StreamsRecord -> Bool
$c/= :: StreamsRecord -> StreamsRecord -> Bool
/= :: StreamsRecord -> StreamsRecord -> Bool
Eq)
instance RedisResult StreamsRecord where
decode :: Reply -> Either Reply StreamsRecord
decode (MultiBulk (Just [Bulk (Just ByteString
recordId), MultiBulk (Just [Reply]
rawKeyValues)])) = do
keyValuesList <- (Reply -> Either Reply ByteString)
-> [Reply] -> Either Reply [ByteString]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode [Reply]
rawKeyValues
let keyValues = [ByteString] -> [(ByteString, ByteString)]
decodeKeyValues [ByteString]
keyValuesList
return StreamsRecord{..}
where
decodeKeyValues :: [ByteString] -> [(ByteString, ByteString)]
decodeKeyValues :: [ByteString] -> [(ByteString, ByteString)]
decodeKeyValues (ByteString
x:ByteString
y:[ByteString]
rest) = (ByteString
x,ByteString
y)(ByteString, ByteString)
-> [(ByteString, ByteString)] -> [(ByteString, ByteString)]
forall a. a -> [a] -> [a]
:[ByteString] -> [(ByteString, ByteString)]
decodeKeyValues [ByteString]
rest
decodeKeyValues [ByteString]
_ = []
decode Reply
a = Reply -> Either Reply StreamsRecord
forall a b. a -> Either a b
Left Reply
a
data XReadOpts = XReadOpts
{ XReadOpts -> Maybe Integer
block :: Maybe Integer
, XReadOpts -> Maybe Integer
recordCount :: Maybe Integer
} deriving (Int -> XReadOpts -> ShowS
[XReadOpts] -> ShowS
XReadOpts -> String
(Int -> XReadOpts -> ShowS)
-> (XReadOpts -> String)
-> ([XReadOpts] -> ShowS)
-> Show XReadOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XReadOpts -> ShowS
showsPrec :: Int -> XReadOpts -> ShowS
$cshow :: XReadOpts -> String
show :: XReadOpts -> String
$cshowList :: [XReadOpts] -> ShowS
showList :: [XReadOpts] -> ShowS
Show, XReadOpts -> XReadOpts -> Bool
(XReadOpts -> XReadOpts -> Bool)
-> (XReadOpts -> XReadOpts -> Bool) -> Eq XReadOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XReadOpts -> XReadOpts -> Bool
== :: XReadOpts -> XReadOpts -> Bool
$c/= :: XReadOpts -> XReadOpts -> Bool
/= :: XReadOpts -> XReadOpts -> Bool
Eq)
defaultXreadOpts :: XReadOpts
defaultXreadOpts :: XReadOpts
defaultXreadOpts = XReadOpts { block :: Maybe Integer
block = Maybe Integer
forall a. Maybe a
Nothing, recordCount :: Maybe Integer
recordCount = Maybe Integer
forall a. Maybe a
Nothing }
data XReadResponse = XReadResponse
{ XReadResponse -> ByteString
stream :: ByteString
, XReadResponse -> [StreamsRecord]
records :: [StreamsRecord]
} deriving (Int -> XReadResponse -> ShowS
[XReadResponse] -> ShowS
XReadResponse -> String
(Int -> XReadResponse -> ShowS)
-> (XReadResponse -> String)
-> ([XReadResponse] -> ShowS)
-> Show XReadResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XReadResponse -> ShowS
showsPrec :: Int -> XReadResponse -> ShowS
$cshow :: XReadResponse -> String
show :: XReadResponse -> String
$cshowList :: [XReadResponse] -> ShowS
showList :: [XReadResponse] -> ShowS
Show, XReadResponse -> XReadResponse -> Bool
(XReadResponse -> XReadResponse -> Bool)
-> (XReadResponse -> XReadResponse -> Bool) -> Eq XReadResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XReadResponse -> XReadResponse -> Bool
== :: XReadResponse -> XReadResponse -> Bool
$c/= :: XReadResponse -> XReadResponse -> Bool
/= :: XReadResponse -> XReadResponse -> Bool
Eq)
instance RedisResult XReadResponse where
decode :: Reply -> Either Reply XReadResponse
decode (MultiBulk (Just [Bulk (Just ByteString
stream), MultiBulk (Just [Reply]
rawRecords)])) = do
records <- (Reply -> Either Reply StreamsRecord)
-> [Reply] -> Either Reply [StreamsRecord]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply StreamsRecord
forall a. RedisResult a => Reply -> Either Reply a
decode [Reply]
rawRecords
return XReadResponse{..}
decode Reply
a = Reply -> Either Reply XReadResponse
forall a b. a -> Either a b
Left Reply
a
xreadOpts
:: (RedisCtx m f)
=> [(ByteString, ByteString)]
-> XReadOpts
-> m (f (Maybe [XReadResponse]))
xreadOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
[(ByteString, ByteString)]
-> XReadOpts -> m (f (Maybe [XReadResponse]))
xreadOpts [(ByteString, ByteString)]
streamsAndIds XReadOpts
opts = [ByteString] -> m (f (Maybe [XReadResponse]))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe [XReadResponse])))
-> [ByteString] -> m (f (Maybe [XReadResponse]))
forall a b. (a -> b) -> a -> b
$
[ByteString
"XREAD"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ([(ByteString, ByteString)] -> XReadOpts -> [ByteString]
internalXreadArgs [(ByteString, ByteString)]
streamsAndIds XReadOpts
opts)
internalXreadArgs :: [(ByteString, ByteString)] -> XReadOpts -> [ByteString]
internalXreadArgs :: [(ByteString, ByteString)] -> XReadOpts -> [ByteString]
internalXreadArgs [(ByteString, ByteString)]
streamsAndIds XReadOpts{Maybe Integer
block :: XReadOpts -> Maybe Integer
recordCount :: XReadOpts -> Maybe Integer
block :: Maybe Integer
recordCount :: Maybe Integer
..} =
[[ByteString]] -> [ByteString]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[ByteString]
blockArgs, [ByteString]
countArgs, [ByteString
"STREAMS"], [ByteString]
streams, [ByteString]
recordIds]
where
blockArgs :: [ByteString]
blockArgs = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
blockMillis -> [ByteString
"BLOCK", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
blockMillis]) Maybe Integer
block
countArgs :: [ByteString]
countArgs = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
countRecords -> [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
countRecords]) Maybe Integer
recordCount
streams :: [ByteString]
streams = ((ByteString, ByteString) -> ByteString)
-> [(ByteString, ByteString)] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map (\(ByteString
stream, ByteString
_) -> ByteString
stream) [(ByteString, ByteString)]
streamsAndIds
recordIds :: [ByteString]
recordIds = ((ByteString, ByteString) -> ByteString)
-> [(ByteString, ByteString)] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map (\(ByteString
_, ByteString
recordId) -> ByteString
recordId) [(ByteString, ByteString)]
streamsAndIds
xread
:: (RedisCtx m f)
=> [(ByteString, ByteString)]
-> m( f (Maybe [XReadResponse]))
xread :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
[(ByteString, ByteString)] -> m (f (Maybe [XReadResponse]))
xread [(ByteString, ByteString)]
streamsAndIds = [(ByteString, ByteString)]
-> XReadOpts -> m (f (Maybe [XReadResponse]))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
[(ByteString, ByteString)]
-> XReadOpts -> m (f (Maybe [XReadResponse]))
xreadOpts [(ByteString, ByteString)]
streamsAndIds XReadOpts
defaultXreadOpts
data XReadGroupOpts = XReadGroupOpts
{ XReadGroupOpts -> Maybe Integer
xReadGroupBlock :: Maybe Integer
, XReadGroupOpts -> Maybe Integer
xReadGroupCount :: Maybe Integer
, XReadGroupOpts -> Bool
xReadGroupNoAck :: Bool
} deriving (Int -> XReadGroupOpts -> ShowS
[XReadGroupOpts] -> ShowS
XReadGroupOpts -> String
(Int -> XReadGroupOpts -> ShowS)
-> (XReadGroupOpts -> String)
-> ([XReadGroupOpts] -> ShowS)
-> Show XReadGroupOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XReadGroupOpts -> ShowS
showsPrec :: Int -> XReadGroupOpts -> ShowS
$cshow :: XReadGroupOpts -> String
show :: XReadGroupOpts -> String
$cshowList :: [XReadGroupOpts] -> ShowS
showList :: [XReadGroupOpts] -> ShowS
Show, XReadGroupOpts -> XReadGroupOpts -> Bool
(XReadGroupOpts -> XReadGroupOpts -> Bool)
-> (XReadGroupOpts -> XReadGroupOpts -> Bool) -> Eq XReadGroupOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XReadGroupOpts -> XReadGroupOpts -> Bool
== :: XReadGroupOpts -> XReadGroupOpts -> Bool
$c/= :: XReadGroupOpts -> XReadGroupOpts -> Bool
/= :: XReadGroupOpts -> XReadGroupOpts -> Bool
Eq)
defaultXReadGroupOpts :: XReadGroupOpts
defaultXReadGroupOpts :: XReadGroupOpts
defaultXReadGroupOpts = XReadGroupOpts
{ xReadGroupBlock :: Maybe Integer
xReadGroupBlock = Maybe Integer
forall a. Maybe a
Nothing
, xReadGroupCount :: Maybe Integer
xReadGroupCount = Maybe Integer
forall a. Maybe a
Nothing
, xReadGroupNoAck :: Bool
xReadGroupNoAck = Bool
False
}
xreadGroupOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> XReadGroupOpts
-> m (f (Maybe [XReadResponse]))
xreadGroupOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> XReadGroupOpts
-> m (f (Maybe [XReadResponse]))
xreadGroupOpts ByteString
groupName ByteString
consumerName [(ByteString, ByteString)]
streamsAndIds XReadGroupOpts{Bool
Maybe Integer
xReadGroupBlock :: XReadGroupOpts -> Maybe Integer
xReadGroupCount :: XReadGroupOpts -> Maybe Integer
xReadGroupNoAck :: XReadGroupOpts -> Bool
xReadGroupBlock :: Maybe Integer
xReadGroupCount :: Maybe Integer
xReadGroupNoAck :: Bool
..} = [ByteString] -> m (f (Maybe [XReadResponse]))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe [XReadResponse])))
-> [ByteString] -> m (f (Maybe [XReadResponse]))
forall a b. (a -> b) -> a -> b
$
[ByteString
"XREADGROUP", ByteString
"GROUP", ByteString
groupName, ByteString
consumerName] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
internalXreadGroupArgs
where
internalXreadGroupArgs :: [ByteString]
internalXreadGroupArgs = [[ByteString]] -> [ByteString]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[ByteString]
countArgs, [ByteString]
blockArgs, [ByteString]
noAckArgs, [ByteString
"STREAMS"], [ByteString]
streams, [ByteString]
recordIds]
blockArgs :: [ByteString]
blockArgs = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
blockMillis -> [ByteString
"BLOCK", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
blockMillis]) Maybe Integer
xReadGroupBlock
countArgs :: [ByteString]
countArgs = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
countRecords -> [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
countRecords]) Maybe Integer
xReadGroupCount
noAckArgs :: [ByteString]
noAckArgs = [ByteString
"NOACK" | Bool
xReadGroupNoAck]
streams :: [ByteString]
streams = ((ByteString, ByteString) -> ByteString)
-> [(ByteString, ByteString)] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map (\(ByteString
stream, ByteString
_) -> ByteString
stream) [(ByteString, ByteString)]
streamsAndIds
recordIds :: [ByteString]
recordIds = ((ByteString, ByteString) -> ByteString)
-> [(ByteString, ByteString)] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map (\(ByteString
_, ByteString
recordId) -> ByteString
recordId) [(ByteString, ByteString)]
streamsAndIds
xreadGroup
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> m (f (Maybe [XReadResponse]))
xreadGroup :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> m (f (Maybe [XReadResponse]))
xreadGroup ByteString
groupName ByteString
consumerName [(ByteString, ByteString)]
streamsAndIds = ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> XReadGroupOpts
-> m (f (Maybe [XReadResponse]))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> [(ByteString, ByteString)]
-> XReadGroupOpts
-> m (f (Maybe [XReadResponse]))
xreadGroupOpts ByteString
groupName ByteString
consumerName [(ByteString, ByteString)]
streamsAndIds XReadGroupOpts
defaultXReadGroupOpts
data XGroupCreateOpts = XGroupCreateOpts
{ XGroupCreateOpts -> Bool
xGroupCreateMkStream :: Bool
, XGroupCreateOpts -> Maybe ByteString
xGroupCreateEntriesRead :: Maybe ByteString
} deriving (Int -> XGroupCreateOpts -> ShowS
[XGroupCreateOpts] -> ShowS
XGroupCreateOpts -> String
(Int -> XGroupCreateOpts -> ShowS)
-> (XGroupCreateOpts -> String)
-> ([XGroupCreateOpts] -> ShowS)
-> Show XGroupCreateOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XGroupCreateOpts -> ShowS
showsPrec :: Int -> XGroupCreateOpts -> ShowS
$cshow :: XGroupCreateOpts -> String
show :: XGroupCreateOpts -> String
$cshowList :: [XGroupCreateOpts] -> ShowS
showList :: [XGroupCreateOpts] -> ShowS
Show, XGroupCreateOpts -> XGroupCreateOpts -> Bool
(XGroupCreateOpts -> XGroupCreateOpts -> Bool)
-> (XGroupCreateOpts -> XGroupCreateOpts -> Bool)
-> Eq XGroupCreateOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XGroupCreateOpts -> XGroupCreateOpts -> Bool
== :: XGroupCreateOpts -> XGroupCreateOpts -> Bool
$c/= :: XGroupCreateOpts -> XGroupCreateOpts -> Bool
/= :: XGroupCreateOpts -> XGroupCreateOpts -> Bool
Eq)
defaultXGroupCreateOpts :: XGroupCreateOpts
defaultXGroupCreateOpts :: XGroupCreateOpts
defaultXGroupCreateOpts = XGroupCreateOpts{
xGroupCreateEntriesRead :: Maybe ByteString
xGroupCreateEntriesRead = Maybe ByteString
forall a. Maybe a
Nothing,
xGroupCreateMkStream :: Bool
xGroupCreateMkStream = Bool
False
}
xgroupCreate
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> m (f Status)
xgroupCreate :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Status)
xgroupCreate ByteString
stream ByteString
groupName ByteString
startId = ByteString
-> ByteString -> ByteString -> XGroupCreateOpts -> m (f Status)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> XGroupCreateOpts -> m (f Status)
xgroupCreateOpts ByteString
stream ByteString
groupName ByteString
startId XGroupCreateOpts
defaultXGroupCreateOpts
xgroupCreateOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> XGroupCreateOpts
-> m (f Status)
xgroupCreateOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> XGroupCreateOpts -> m (f Status)
xgroupCreateOpts ByteString
stream ByteString
groupName ByteString
startId XGroupCreateOpts
opts = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$ [ByteString
"XGROUP", ByteString
"CREATE", ByteString
stream, ByteString
groupName, ByteString
startId] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
args
where args :: [ByteString]
args = [ByteString]
mkstream [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
entriesRead
mkstream :: [ByteString]
mkstream = [ByteString
"MKSTREAM" | XGroupCreateOpts -> Bool
xGroupCreateMkStream XGroupCreateOpts
opts]
entriesRead :: [ByteString]
entriesRead = [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((ByteString
"ENTRIESREAD"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:) ([ByteString] -> [ByteString])
-> (ByteString -> [ByteString]) -> ByteString -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[])) (XGroupCreateOpts -> Maybe ByteString
xGroupCreateEntriesRead XGroupCreateOpts
opts)
xgroupCreateConsumer
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> m (f Bool)
xgroupCreateConsumer :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Bool)
xgroupCreateConsumer ByteString
key ByteString
group ByteString
consumer = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"XGROUP", ByteString
"CREATECONSUMER", ByteString
key, ByteString
group, ByteString
consumer]
xgroupSetId
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> m (f Status)
xgroupSetId :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Status)
xgroupSetId ByteString
stream ByteString
group ByteString
messageId = ByteString
-> ByteString -> ByteString -> XGroupSetIdOpts -> m (f Status)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> XGroupSetIdOpts -> m (f Status)
xgroupSetIdOpts ByteString
stream ByteString
group ByteString
messageId XGroupSetIdOpts
defaultXGroupSetIdOpts
newtype XGroupSetIdOpts = XGroupSetIdOpts {
XGroupSetIdOpts -> Maybe ByteString
xGroupSetIdEntriesRead :: Maybe ByteString
}
defaultXGroupSetIdOpts :: XGroupSetIdOpts
defaultXGroupSetIdOpts :: XGroupSetIdOpts
defaultXGroupSetIdOpts = XGroupSetIdOpts {xGroupSetIdEntriesRead :: Maybe ByteString
xGroupSetIdEntriesRead = Maybe ByteString
forall a. Maybe a
Nothing}
xgroupSetIdOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> XGroupSetIdOpts
-> m (f Status)
xgroupSetIdOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> XGroupSetIdOpts -> m (f Status)
xgroupSetIdOpts ByteString
stream ByteString
group ByteString
messageId XGroupSetIdOpts
opts = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$ [ByteString
"XGROUP", ByteString
"SETID", ByteString
stream, ByteString
group, ByteString
messageId] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
entriesRead
where entriesRead :: [ByteString]
entriesRead = [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((ByteString
"ENTRIESREAD"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:) ([ByteString] -> [ByteString])
-> (ByteString -> [ByteString]) -> ByteString -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[])) (XGroupSetIdOpts -> Maybe ByteString
xGroupSetIdEntriesRead XGroupSetIdOpts
opts)
xgroupDelConsumer
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> m (f Integer)
xgroupDelConsumer :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> ByteString -> m (f Integer)
xgroupDelConsumer ByteString
stream ByteString
group ByteString
consumer = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"XGROUP", ByteString
"DELCONSUMER", ByteString
stream, ByteString
group, ByteString
consumer]
xgroupDestroy
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f Bool)
xgroupDestroy :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f Bool)
xgroupDestroy ByteString
stream ByteString
group = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"XGROUP", ByteString
"DESTROY", ByteString
stream, ByteString
group]
data XRefPolicy
= XRefPolicyKeepRef
| XRefPolicyDelRef
| XRefPolicyAcked
deriving (Int -> XRefPolicy -> ShowS
[XRefPolicy] -> ShowS
XRefPolicy -> String
(Int -> XRefPolicy -> ShowS)
-> (XRefPolicy -> String)
-> ([XRefPolicy] -> ShowS)
-> Show XRefPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XRefPolicy -> ShowS
showsPrec :: Int -> XRefPolicy -> ShowS
$cshow :: XRefPolicy -> String
show :: XRefPolicy -> String
$cshowList :: [XRefPolicy] -> ShowS
showList :: [XRefPolicy] -> ShowS
Show, XRefPolicy -> XRefPolicy -> Bool
(XRefPolicy -> XRefPolicy -> Bool)
-> (XRefPolicy -> XRefPolicy -> Bool) -> Eq XRefPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XRefPolicy -> XRefPolicy -> Bool
== :: XRefPolicy -> XRefPolicy -> Bool
$c/= :: XRefPolicy -> XRefPolicy -> Bool
/= :: XRefPolicy -> XRefPolicy -> Bool
Eq)
instance RedisArg XRefPolicy where
encode :: XRefPolicy -> ByteString
encode XRefPolicy
XRefPolicyKeepRef = ByteString
"KEEPREF"
encode XRefPolicy
XRefPolicyDelRef = ByteString
"DELREF"
encode XRefPolicy
XRefPolicyAcked = ByteString
"ACKED"
data XEntryDeletionOpts = XEntryDeletionOpts
{ XEntryDeletionOpts -> XRefPolicy
xEntryDeletionRefPolicy :: XRefPolicy
} deriving (Int -> XEntryDeletionOpts -> ShowS
[XEntryDeletionOpts] -> ShowS
XEntryDeletionOpts -> String
(Int -> XEntryDeletionOpts -> ShowS)
-> (XEntryDeletionOpts -> String)
-> ([XEntryDeletionOpts] -> ShowS)
-> Show XEntryDeletionOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XEntryDeletionOpts -> ShowS
showsPrec :: Int -> XEntryDeletionOpts -> ShowS
$cshow :: XEntryDeletionOpts -> String
show :: XEntryDeletionOpts -> String
$cshowList :: [XEntryDeletionOpts] -> ShowS
showList :: [XEntryDeletionOpts] -> ShowS
Show, XEntryDeletionOpts -> XEntryDeletionOpts -> Bool
(XEntryDeletionOpts -> XEntryDeletionOpts -> Bool)
-> (XEntryDeletionOpts -> XEntryDeletionOpts -> Bool)
-> Eq XEntryDeletionOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XEntryDeletionOpts -> XEntryDeletionOpts -> Bool
== :: XEntryDeletionOpts -> XEntryDeletionOpts -> Bool
$c/= :: XEntryDeletionOpts -> XEntryDeletionOpts -> Bool
/= :: XEntryDeletionOpts -> XEntryDeletionOpts -> Bool
Eq)
defaultXEntryDeletionOpts :: XEntryDeletionOpts
defaultXEntryDeletionOpts :: XEntryDeletionOpts
defaultXEntryDeletionOpts = XEntryDeletionOpts
{ xEntryDeletionRefPolicy :: XRefPolicy
xEntryDeletionRefPolicy = XRefPolicy
XRefPolicyKeepRef
}
data XCfgSetOpts = XCfgSetOpts
{ XCfgSetOpts -> Maybe Integer
xCfgSetIdmpDuration :: Maybe Integer
, XCfgSetOpts -> Maybe Integer
xCfgSetIdmpMaxsize :: Maybe Integer
} deriving (Int -> XCfgSetOpts -> ShowS
[XCfgSetOpts] -> ShowS
XCfgSetOpts -> String
(Int -> XCfgSetOpts -> ShowS)
-> (XCfgSetOpts -> String)
-> ([XCfgSetOpts] -> ShowS)
-> Show XCfgSetOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XCfgSetOpts -> ShowS
showsPrec :: Int -> XCfgSetOpts -> ShowS
$cshow :: XCfgSetOpts -> String
show :: XCfgSetOpts -> String
$cshowList :: [XCfgSetOpts] -> ShowS
showList :: [XCfgSetOpts] -> ShowS
Show, XCfgSetOpts -> XCfgSetOpts -> Bool
(XCfgSetOpts -> XCfgSetOpts -> Bool)
-> (XCfgSetOpts -> XCfgSetOpts -> Bool) -> Eq XCfgSetOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XCfgSetOpts -> XCfgSetOpts -> Bool
== :: XCfgSetOpts -> XCfgSetOpts -> Bool
$c/= :: XCfgSetOpts -> XCfgSetOpts -> Bool
/= :: XCfgSetOpts -> XCfgSetOpts -> Bool
Eq)
defaultXCfgSetOpts :: XCfgSetOpts
defaultXCfgSetOpts :: XCfgSetOpts
defaultXCfgSetOpts = XCfgSetOpts
{ xCfgSetIdmpDuration :: Maybe Integer
xCfgSetIdmpDuration = Maybe Integer
forall a. Maybe a
Nothing
, xCfgSetIdmpMaxsize :: Maybe Integer
xCfgSetIdmpMaxsize = Maybe Integer
forall a. Maybe a
Nothing
}
data XNackMode
= XNackSilent
| XNackFail
| XNackFatal
deriving (Int -> XNackMode -> ShowS
[XNackMode] -> ShowS
XNackMode -> String
(Int -> XNackMode -> ShowS)
-> (XNackMode -> String)
-> ([XNackMode] -> ShowS)
-> Show XNackMode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XNackMode -> ShowS
showsPrec :: Int -> XNackMode -> ShowS
$cshow :: XNackMode -> String
show :: XNackMode -> String
$cshowList :: [XNackMode] -> ShowS
showList :: [XNackMode] -> ShowS
Show, XNackMode -> XNackMode -> Bool
(XNackMode -> XNackMode -> Bool)
-> (XNackMode -> XNackMode -> Bool) -> Eq XNackMode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XNackMode -> XNackMode -> Bool
== :: XNackMode -> XNackMode -> Bool
$c/= :: XNackMode -> XNackMode -> Bool
/= :: XNackMode -> XNackMode -> Bool
Eq)
instance RedisArg XNackMode where
encode :: XNackMode -> ByteString
encode XNackMode
XNackSilent = ByteString
"SILENT"
encode XNackMode
XNackFail = ByteString
"FAIL"
encode XNackMode
XNackFatal = ByteString
"FATAL"
data XNackOpts = XNackOpts
{ XNackOpts -> Maybe Integer
xNackRetryCount :: Maybe Integer
, XNackOpts -> Bool
xNackForce :: Bool
} deriving (Int -> XNackOpts -> ShowS
[XNackOpts] -> ShowS
XNackOpts -> String
(Int -> XNackOpts -> ShowS)
-> (XNackOpts -> String)
-> ([XNackOpts] -> ShowS)
-> Show XNackOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XNackOpts -> ShowS
showsPrec :: Int -> XNackOpts -> ShowS
$cshow :: XNackOpts -> String
show :: XNackOpts -> String
$cshowList :: [XNackOpts] -> ShowS
showList :: [XNackOpts] -> ShowS
Show, XNackOpts -> XNackOpts -> Bool
(XNackOpts -> XNackOpts -> Bool)
-> (XNackOpts -> XNackOpts -> Bool) -> Eq XNackOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XNackOpts -> XNackOpts -> Bool
== :: XNackOpts -> XNackOpts -> Bool
$c/= :: XNackOpts -> XNackOpts -> Bool
/= :: XNackOpts -> XNackOpts -> Bool
Eq)
defaultXNackOpts :: XNackOpts
defaultXNackOpts :: XNackOpts
defaultXNackOpts = XNackOpts
{ xNackRetryCount :: Maybe Integer
xNackRetryCount = Maybe Integer
forall a. Maybe a
Nothing
, xNackForce :: Bool
xNackForce = Bool
False
}
data XEntryDeletionResult
= XEntryDeletionResultNotFound
| XEntryDeletionResultDeleted
| XEntryDeletionResultNotDeleted
deriving (Int -> XEntryDeletionResult -> ShowS
[XEntryDeletionResult] -> ShowS
XEntryDeletionResult -> String
(Int -> XEntryDeletionResult -> ShowS)
-> (XEntryDeletionResult -> String)
-> ([XEntryDeletionResult] -> ShowS)
-> Show XEntryDeletionResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XEntryDeletionResult -> ShowS
showsPrec :: Int -> XEntryDeletionResult -> ShowS
$cshow :: XEntryDeletionResult -> String
show :: XEntryDeletionResult -> String
$cshowList :: [XEntryDeletionResult] -> ShowS
showList :: [XEntryDeletionResult] -> ShowS
Show, XEntryDeletionResult -> XEntryDeletionResult -> Bool
(XEntryDeletionResult -> XEntryDeletionResult -> Bool)
-> (XEntryDeletionResult -> XEntryDeletionResult -> Bool)
-> Eq XEntryDeletionResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XEntryDeletionResult -> XEntryDeletionResult -> Bool
== :: XEntryDeletionResult -> XEntryDeletionResult -> Bool
$c/= :: XEntryDeletionResult -> XEntryDeletionResult -> Bool
/= :: XEntryDeletionResult -> XEntryDeletionResult -> Bool
Eq)
instance RedisResult XEntryDeletionResult where
decode :: Reply -> Either Reply XEntryDeletionResult
decode Reply
r = do
result <- Reply -> Either Reply Integer
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
r :: Either Reply Integer
case result of
-1 -> XEntryDeletionResult -> Either Reply XEntryDeletionResult
forall a b. b -> Either a b
Right XEntryDeletionResult
XEntryDeletionResultNotFound
Integer
1 -> XEntryDeletionResult -> Either Reply XEntryDeletionResult
forall a b. b -> Either a b
Right XEntryDeletionResult
XEntryDeletionResultDeleted
Integer
2 -> XEntryDeletionResult -> Either Reply XEntryDeletionResult
forall a b. b -> Either a b
Right XEntryDeletionResult
XEntryDeletionResultNotDeleted
Integer
_ -> Reply -> Either Reply XEntryDeletionResult
forall a b. a -> Either a b
Left Reply
r
xEntryDeletionOptsToArgs :: XEntryDeletionOpts -> [ByteString]
xEntryDeletionOptsToArgs :: XEntryDeletionOpts -> [ByteString]
xEntryDeletionOptsToArgs XEntryDeletionOpts{XRefPolicy
xEntryDeletionRefPolicy :: XEntryDeletionOpts -> XRefPolicy
xEntryDeletionRefPolicy :: XRefPolicy
..} =
[XRefPolicy -> ByteString
forall a. RedisArg a => a -> ByteString
encode XRefPolicy
xEntryDeletionRefPolicy]
xEntryIdsBlockArgs :: NonEmpty ByteString -> [ByteString]
xEntryIdsBlockArgs :: NonEmpty ByteString -> [ByteString]
xEntryIdsBlockArgs NonEmpty ByteString
messageIds =
[ByteString
"IDS", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty ByteString -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty ByteString
messageIds)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
messageIds
xack
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> [ByteString]
-> m (f Integer)
xack :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> [ByteString] -> m (f Integer)
xack ByteString
stream ByteString
groupName [ByteString]
messageIds = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"XACK", ByteString
stream, ByteString
groupName] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
messageIds
xackdel
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> NonEmpty ByteString
-> m (f [XEntryDeletionResult])
xackdel :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> NonEmpty ByteString
-> m (f [XEntryDeletionResult])
xackdel ByteString
stream ByteString
groupName NonEmpty ByteString
messageIds =
ByteString
-> ByteString
-> NonEmpty ByteString
-> XEntryDeletionOpts
-> m (f [XEntryDeletionResult])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> NonEmpty ByteString
-> XEntryDeletionOpts
-> m (f [XEntryDeletionResult])
xackdelOpts ByteString
stream ByteString
groupName NonEmpty ByteString
messageIds XEntryDeletionOpts
defaultXEntryDeletionOpts
xackdelOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> NonEmpty ByteString
-> XEntryDeletionOpts
-> m (f [XEntryDeletionResult])
xackdelOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> NonEmpty ByteString
-> XEntryDeletionOpts
-> m (f [XEntryDeletionResult])
xackdelOpts ByteString
stream ByteString
groupName NonEmpty ByteString
messageIds XEntryDeletionOpts
opts =
[ByteString] -> m (f [XEntryDeletionResult])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [XEntryDeletionResult]))
-> [ByteString] -> m (f [XEntryDeletionResult])
forall a b. (a -> b) -> a -> b
$ [ByteString
"XACKDEL", ByteString
stream, ByteString
groupName]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ XEntryDeletionOpts -> [ByteString]
xEntryDeletionOptsToArgs XEntryDeletionOpts
opts
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
xEntryIdsBlockArgs NonEmpty ByteString
messageIds
xrange
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Maybe Integer
-> m (f [StreamsRecord])
xrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Maybe Integer
-> m (f [StreamsRecord])
xrange ByteString
stream ByteString
start ByteString
end Maybe Integer
count = [ByteString] -> m (f [StreamsRecord])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [StreamsRecord]))
-> [ByteString] -> m (f [StreamsRecord])
forall a b. (a -> b) -> a -> b
$ [ByteString
"XRANGE", ByteString
stream, ByteString
start, ByteString
end] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
countArgs
where countArgs :: [ByteString]
countArgs = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
c -> [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
c]) Maybe Integer
count
xrevRange
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Maybe Integer
-> m (f [StreamsRecord])
xrevRange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Maybe Integer
-> m (f [StreamsRecord])
xrevRange ByteString
stream ByteString
end ByteString
start Maybe Integer
count = [ByteString] -> m (f [StreamsRecord])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [StreamsRecord]))
-> [ByteString] -> m (f [StreamsRecord])
forall a b. (a -> b) -> a -> b
$ [ByteString
"XREVRANGE", ByteString
stream, ByteString
end, ByteString
start] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
countArgs
where countArgs :: [ByteString]
countArgs = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
c -> [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
c]) Maybe Integer
count
xlen
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
xlen :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
xlen ByteString
stream = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"XLEN", ByteString
stream]
data XPendingSummaryResponse = XPendingSummaryResponse
{ XPendingSummaryResponse -> Integer
numPendingMessages :: Integer
, XPendingSummaryResponse -> ByteString
smallestPendingMessageId :: ByteString
, XPendingSummaryResponse -> ByteString
largestPendingMessageId :: ByteString
, XPendingSummaryResponse -> [(ByteString, Integer)]
numPendingMessagesByconsumer :: [(ByteString, Integer)]
} deriving (Int -> XPendingSummaryResponse -> ShowS
[XPendingSummaryResponse] -> ShowS
XPendingSummaryResponse -> String
(Int -> XPendingSummaryResponse -> ShowS)
-> (XPendingSummaryResponse -> String)
-> ([XPendingSummaryResponse] -> ShowS)
-> Show XPendingSummaryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XPendingSummaryResponse -> ShowS
showsPrec :: Int -> XPendingSummaryResponse -> ShowS
$cshow :: XPendingSummaryResponse -> String
show :: XPendingSummaryResponse -> String
$cshowList :: [XPendingSummaryResponse] -> ShowS
showList :: [XPendingSummaryResponse] -> ShowS
Show, XPendingSummaryResponse -> XPendingSummaryResponse -> Bool
(XPendingSummaryResponse -> XPendingSummaryResponse -> Bool)
-> (XPendingSummaryResponse -> XPendingSummaryResponse -> Bool)
-> Eq XPendingSummaryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XPendingSummaryResponse -> XPendingSummaryResponse -> Bool
== :: XPendingSummaryResponse -> XPendingSummaryResponse -> Bool
$c/= :: XPendingSummaryResponse -> XPendingSummaryResponse -> Bool
/= :: XPendingSummaryResponse -> XPendingSummaryResponse -> Bool
Eq)
instance RedisResult XPendingSummaryResponse where
decode :: Reply -> Either Reply XPendingSummaryResponse
decode (MultiBulk (Just [
Integer Integer
numPendingMessages,
Bulk (Just ByteString
smallestPendingMessageId),
Bulk (Just ByteString
largestPendingMessageId),
MultiBulk (Just [MultiBulk (Just [Reply]
rawGroupsAndCounts)])])) = do
let groupsAndCounts :: [(Reply, Reply)]
groupsAndCounts = [Reply] -> [(Reply, Reply)]
forall {b}. [b] -> [(b, b)]
chunksOfTwo [Reply]
rawGroupsAndCounts
numPendingMessagesByconsumer <- [(Reply, Reply)] -> Either Reply [(ByteString, Integer)]
decodeGroupsAndCounts [(Reply, Reply)]
groupsAndCounts
return XPendingSummaryResponse{..}
where
decodeGroupsAndCounts :: [(Reply, Reply)] -> Either Reply [(ByteString, Integer)]
decodeGroupsAndCounts :: [(Reply, Reply)] -> Either Reply [(ByteString, Integer)]
decodeGroupsAndCounts [(Reply, Reply)]
bs = [Either Reply (ByteString, Integer)]
-> Either Reply [(ByteString, Integer)]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence ([Either Reply (ByteString, Integer)]
-> Either Reply [(ByteString, Integer)])
-> [Either Reply (ByteString, Integer)]
-> Either Reply [(ByteString, Integer)]
forall a b. (a -> b) -> a -> b
$ ((Reply, Reply) -> Either Reply (ByteString, Integer))
-> [(Reply, Reply)] -> [Either Reply (ByteString, Integer)]
forall a b. (a -> b) -> [a] -> [b]
map (Reply, Reply) -> Either Reply (ByteString, Integer)
decodeGroupCount [(Reply, Reply)]
bs
decodeGroupCount :: (Reply, Reply) -> Either Reply (ByteString, Integer)
decodeGroupCount :: (Reply, Reply) -> Either Reply (ByteString, Integer)
decodeGroupCount (Reply
x, Reply
y) = do
decodedX <- Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
x
decodedY <- decode y
return (decodedX, decodedY)
chunksOfTwo :: [b] -> [(b, b)]
chunksOfTwo (b
x:b
y:[b]
rest) = (b
x,b
y)(b, b) -> [(b, b)] -> [(b, b)]
forall a. a -> [a] -> [a]
:[b] -> [(b, b)]
chunksOfTwo [b]
rest
chunksOfTwo [b]
_ = []
decode Reply
a = Reply -> Either Reply XPendingSummaryResponse
forall a b. a -> Either a b
Left Reply
a
xpendingSummary
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f XPendingSummaryResponse)
xpendingSummary :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f XPendingSummaryResponse)
xpendingSummary ByteString
stream ByteString
group = [ByteString] -> m (f XPendingSummaryResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f XPendingSummaryResponse))
-> [ByteString] -> m (f XPendingSummaryResponse)
forall a b. (a -> b) -> a -> b
$ [ByteString
"XPENDING", ByteString
stream, ByteString
group]
data XPendingDetailRecord = XPendingDetailRecord
{ XPendingDetailRecord -> ByteString
messageId :: ByteString
, XPendingDetailRecord -> ByteString
consumer :: ByteString
, XPendingDetailRecord -> Integer
millisSinceLastDelivered :: Integer
, XPendingDetailRecord -> Integer
numTimesDelivered :: Integer
} deriving (Int -> XPendingDetailRecord -> ShowS
[XPendingDetailRecord] -> ShowS
XPendingDetailRecord -> String
(Int -> XPendingDetailRecord -> ShowS)
-> (XPendingDetailRecord -> String)
-> ([XPendingDetailRecord] -> ShowS)
-> Show XPendingDetailRecord
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XPendingDetailRecord -> ShowS
showsPrec :: Int -> XPendingDetailRecord -> ShowS
$cshow :: XPendingDetailRecord -> String
show :: XPendingDetailRecord -> String
$cshowList :: [XPendingDetailRecord] -> ShowS
showList :: [XPendingDetailRecord] -> ShowS
Show, XPendingDetailRecord -> XPendingDetailRecord -> Bool
(XPendingDetailRecord -> XPendingDetailRecord -> Bool)
-> (XPendingDetailRecord -> XPendingDetailRecord -> Bool)
-> Eq XPendingDetailRecord
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XPendingDetailRecord -> XPendingDetailRecord -> Bool
== :: XPendingDetailRecord -> XPendingDetailRecord -> Bool
$c/= :: XPendingDetailRecord -> XPendingDetailRecord -> Bool
/= :: XPendingDetailRecord -> XPendingDetailRecord -> Bool
Eq)
instance RedisResult XPendingDetailRecord where
decode :: Reply -> Either Reply XPendingDetailRecord
decode (MultiBulk (Just [
Bulk (Just ByteString
messageId) ,
Bulk (Just ByteString
consumer),
Integer Integer
millisSinceLastDelivered,
Integer Integer
numTimesDelivered])) = XPendingDetailRecord -> Either Reply XPendingDetailRecord
forall a b. b -> Either a b
Right XPendingDetailRecord{Integer
ByteString
messageId :: ByteString
consumer :: ByteString
millisSinceLastDelivered :: Integer
numTimesDelivered :: Integer
messageId :: ByteString
consumer :: ByteString
millisSinceLastDelivered :: Integer
numTimesDelivered :: Integer
..}
decode Reply
a = Reply -> Either Reply XPendingDetailRecord
forall a b. a -> Either a b
Left Reply
a
data XPendingDetailOpts = XPendingDetailOpts
{
XPendingDetailOpts -> Maybe ByteString
xPendingDetailConsumer :: Maybe ByteString,
XPendingDetailOpts -> Maybe Integer
xPendingDetailIdle :: Maybe Integer
}
defaultXPendingDetailOpts :: XPendingDetailOpts
defaultXPendingDetailOpts :: XPendingDetailOpts
defaultXPendingDetailOpts = XPendingDetailOpts {
xPendingDetailConsumer :: Maybe ByteString
xPendingDetailConsumer = Maybe ByteString
forall a. Maybe a
Nothing,
xPendingDetailIdle :: Maybe Integer
xPendingDetailIdle = Maybe Integer
forall a. Maybe a
Nothing
}
xpendingDetail
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> ByteString
-> Integer
-> XPendingDetailOpts
-> m (f [XPendingDetailRecord])
xpendingDetail :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> ByteString
-> Integer
-> XPendingDetailOpts
-> m (f [XPendingDetailRecord])
xpendingDetail ByteString
stream ByteString
group ByteString
startId ByteString
endId Integer
count XPendingDetailOpts
opts = [ByteString] -> m (f [XPendingDetailRecord])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [XPendingDetailRecord]))
-> [ByteString] -> m (f [XPendingDetailRecord])
forall a b. (a -> b) -> a -> b
$
[ByteString
"XPENDING", ByteString
stream, ByteString
group] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
idleArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
startId, ByteString
endId, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
consumerArg
where consumerArg :: [ByteString]
consumerArg = Maybe ByteString -> [ByteString]
forall a. Maybe a -> [a]
maybeToList (XPendingDetailOpts -> Maybe ByteString
xPendingDetailConsumer XPendingDetailOpts
opts)
idleArg :: [ByteString]
idleArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((ByteString
"IDLE"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:) ([ByteString] -> [ByteString])
-> (Integer -> [ByteString]) -> Integer -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[]) (ByteString -> [ByteString])
-> (Integer -> ByteString) -> Integer -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode) (XPendingDetailOpts -> Maybe Integer
xPendingDetailIdle XPendingDetailOpts
opts)
data XClaimOpts = XClaimOpts
{ XClaimOpts -> Maybe Integer
xclaimIdle :: Maybe Integer
, XClaimOpts -> Maybe Integer
xclaimTime :: Maybe Integer
, XClaimOpts -> Maybe Integer
xclaimRetryCount :: Maybe Integer
, XClaimOpts -> Bool
xclaimForce :: Bool
} deriving (Int -> XClaimOpts -> ShowS
[XClaimOpts] -> ShowS
XClaimOpts -> String
(Int -> XClaimOpts -> ShowS)
-> (XClaimOpts -> String)
-> ([XClaimOpts] -> ShowS)
-> Show XClaimOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XClaimOpts -> ShowS
showsPrec :: Int -> XClaimOpts -> ShowS
$cshow :: XClaimOpts -> String
show :: XClaimOpts -> String
$cshowList :: [XClaimOpts] -> ShowS
showList :: [XClaimOpts] -> ShowS
Show, XClaimOpts -> XClaimOpts -> Bool
(XClaimOpts -> XClaimOpts -> Bool)
-> (XClaimOpts -> XClaimOpts -> Bool) -> Eq XClaimOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XClaimOpts -> XClaimOpts -> Bool
== :: XClaimOpts -> XClaimOpts -> Bool
$c/= :: XClaimOpts -> XClaimOpts -> Bool
/= :: XClaimOpts -> XClaimOpts -> Bool
Eq)
defaultXClaimOpts :: XClaimOpts
defaultXClaimOpts :: XClaimOpts
defaultXClaimOpts = XClaimOpts
{ xclaimIdle :: Maybe Integer
xclaimIdle = Maybe Integer
forall a. Maybe a
Nothing
, xclaimTime :: Maybe Integer
xclaimTime = Maybe Integer
forall a. Maybe a
Nothing
, xclaimRetryCount :: Maybe Integer
xclaimRetryCount = Maybe Integer
forall a. Maybe a
Nothing
, xclaimForce :: Bool
xclaimForce = Bool
False
}
xclaimRequest
:: ByteString
-> ByteString
-> ByteString
-> Integer
-> XClaimOpts
-> [ByteString]
-> [ByteString]
xclaimRequest :: ByteString
-> ByteString
-> ByteString
-> Integer
-> XClaimOpts
-> [ByteString]
-> [ByteString]
xclaimRequest ByteString
stream ByteString
group ByteString
consumer Integer
minIdleTime XClaimOpts{Bool
Maybe Integer
xclaimIdle :: XClaimOpts -> Maybe Integer
xclaimTime :: XClaimOpts -> Maybe Integer
xclaimRetryCount :: XClaimOpts -> Maybe Integer
xclaimForce :: XClaimOpts -> Bool
xclaimIdle :: Maybe Integer
xclaimTime :: Maybe Integer
xclaimRetryCount :: Maybe Integer
xclaimForce :: Bool
..} [ByteString]
messageIds =
[ByteString
"XCLAIM", ByteString
stream, ByteString
group, ByteString
consumer, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
minIdleTime] [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]
messageIds ) [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
optArgs
where optArgs :: [ByteString]
optArgs = [ByteString]
idleArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
timeArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
retryCountArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
forceArg
idleArg :: [ByteString]
idleArg = ByteString -> Maybe Integer -> [ByteString]
forall {a}. RedisArg a => ByteString -> Maybe a -> [ByteString]
optArg ByteString
"IDLE" Maybe Integer
xclaimIdle
timeArg :: [ByteString]
timeArg = ByteString -> Maybe Integer -> [ByteString]
forall {a}. RedisArg a => ByteString -> Maybe a -> [ByteString]
optArg ByteString
"TIME" Maybe Integer
xclaimTime
retryCountArg :: [ByteString]
retryCountArg = ByteString -> Maybe Integer -> [ByteString]
forall {a}. RedisArg a => ByteString -> Maybe a -> [ByteString]
optArg ByteString
"RETRYCOUNT" Maybe Integer
xclaimRetryCount
forceArg :: [ByteString]
forceArg = if Bool
xclaimForce then [ByteString
"FORCE"] else []
optArg :: ByteString -> Maybe a -> [ByteString]
optArg ByteString
name Maybe a
maybeArg = [ByteString] -> (a -> [ByteString]) -> Maybe a -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\a
x -> [ByteString
name, a -> ByteString
forall a. RedisArg a => a -> ByteString
encode a
x]) Maybe a
maybeArg
xclaim
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Integer
-> XClaimOpts
-> [ByteString]
-> m (f [StreamsRecord])
xclaim :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Integer
-> XClaimOpts
-> [ByteString]
-> m (f [StreamsRecord])
xclaim ByteString
stream ByteString
group ByteString
consumer Integer
minIdleTime XClaimOpts
opts [ByteString]
messageIds = [ByteString] -> m (f [StreamsRecord])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [StreamsRecord]))
-> [ByteString] -> m (f [StreamsRecord])
forall a b. (a -> b) -> a -> b
$
ByteString
-> ByteString
-> ByteString
-> Integer
-> XClaimOpts
-> [ByteString]
-> [ByteString]
xclaimRequest ByteString
stream ByteString
group ByteString
consumer Integer
minIdleTime XClaimOpts
opts [ByteString]
messageIds
xclaimJustIds
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Integer
-> XClaimOpts
-> [ByteString]
-> m (f [ByteString])
xclaimJustIds :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Integer
-> XClaimOpts
-> [ByteString]
-> m (f [ByteString])
xclaimJustIds ByteString
stream ByteString
group ByteString
consumer Integer
minIdleTime XClaimOpts
opts [ByteString]
messageIds = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [ByteString]))
-> [ByteString] -> m (f [ByteString])
forall a b. (a -> b) -> a -> b
$
(ByteString
-> ByteString
-> ByteString
-> Integer
-> XClaimOpts
-> [ByteString]
-> [ByteString]
xclaimRequest ByteString
stream ByteString
group ByteString
consumer Integer
minIdleTime XClaimOpts
opts [ByteString]
messageIds) [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"JUSTID"]
data GeoUnit
= GeoMeters
| GeoKilometers
| GeoFeet
| GeoMiles
deriving (Int -> GeoUnit -> ShowS
[GeoUnit] -> ShowS
GeoUnit -> String
(Int -> GeoUnit -> ShowS)
-> (GeoUnit -> String) -> ([GeoUnit] -> ShowS) -> Show GeoUnit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GeoUnit -> ShowS
showsPrec :: Int -> GeoUnit -> ShowS
$cshow :: GeoUnit -> String
show :: GeoUnit -> String
$cshowList :: [GeoUnit] -> ShowS
showList :: [GeoUnit] -> ShowS
Show, GeoUnit -> GeoUnit -> Bool
(GeoUnit -> GeoUnit -> Bool)
-> (GeoUnit -> GeoUnit -> Bool) -> Eq GeoUnit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GeoUnit -> GeoUnit -> Bool
== :: GeoUnit -> GeoUnit -> Bool
$c/= :: GeoUnit -> GeoUnit -> Bool
/= :: GeoUnit -> GeoUnit -> Bool
Eq)
instance RedisArg GeoUnit where
encode :: GeoUnit -> ByteString
encode GeoUnit
GeoMeters = ByteString
"m"
encode GeoUnit
GeoKilometers = ByteString
"km"
encode GeoUnit
GeoFeet = ByteString
"ft"
encode GeoUnit
GeoMiles = ByteString
"mi"
data GeoOrder
= GeoAsc
| GeoDesc
deriving (Int -> GeoOrder -> ShowS
[GeoOrder] -> ShowS
GeoOrder -> String
(Int -> GeoOrder -> ShowS)
-> (GeoOrder -> String) -> ([GeoOrder] -> ShowS) -> Show GeoOrder
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GeoOrder -> ShowS
showsPrec :: Int -> GeoOrder -> ShowS
$cshow :: GeoOrder -> String
show :: GeoOrder -> String
$cshowList :: [GeoOrder] -> ShowS
showList :: [GeoOrder] -> ShowS
Show, GeoOrder -> GeoOrder -> Bool
(GeoOrder -> GeoOrder -> Bool)
-> (GeoOrder -> GeoOrder -> Bool) -> Eq GeoOrder
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GeoOrder -> GeoOrder -> Bool
== :: GeoOrder -> GeoOrder -> Bool
$c/= :: GeoOrder -> GeoOrder -> Bool
/= :: GeoOrder -> GeoOrder -> Bool
Eq)
instance RedisArg GeoOrder where
encode :: GeoOrder -> ByteString
encode GeoOrder
GeoAsc = ByteString
"ASC"
encode GeoOrder
GeoDesc = ByteString
"DESC"
data GeoCoordinates = GeoCoordinates
{ GeoCoordinates -> Double
geoLongitude :: Double
, GeoCoordinates -> Double
geoLatitude :: Double
} deriving (Int -> GeoCoordinates -> ShowS
[GeoCoordinates] -> ShowS
GeoCoordinates -> String
(Int -> GeoCoordinates -> ShowS)
-> (GeoCoordinates -> String)
-> ([GeoCoordinates] -> ShowS)
-> Show GeoCoordinates
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GeoCoordinates -> ShowS
showsPrec :: Int -> GeoCoordinates -> ShowS
$cshow :: GeoCoordinates -> String
show :: GeoCoordinates -> String
$cshowList :: [GeoCoordinates] -> ShowS
showList :: [GeoCoordinates] -> ShowS
Show, GeoCoordinates -> GeoCoordinates -> Bool
(GeoCoordinates -> GeoCoordinates -> Bool)
-> (GeoCoordinates -> GeoCoordinates -> Bool) -> Eq GeoCoordinates
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GeoCoordinates -> GeoCoordinates -> Bool
== :: GeoCoordinates -> GeoCoordinates -> Bool
$c/= :: GeoCoordinates -> GeoCoordinates -> Bool
/= :: GeoCoordinates -> GeoCoordinates -> Bool
Eq)
instance RedisResult GeoCoordinates where
decode :: Reply -> Either Reply GeoCoordinates
decode (MultiBulk (Just [Reply
lon, Reply
lat])) =
Double -> Double -> GeoCoordinates
GeoCoordinates (Double -> Double -> GeoCoordinates)
-> Either Reply Double -> Either Reply (Double -> GeoCoordinates)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply Double
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
lon Either Reply (Double -> GeoCoordinates)
-> Either Reply Double -> Either Reply GeoCoordinates
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Double
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
lat
decode Reply
r = Reply -> Either Reply GeoCoordinates
forall a b. a -> Either a b
Left Reply
r
data GeoLocation = GeoLocation
{ GeoLocation -> ByteString
geoLocationMember :: ByteString
, GeoLocation -> Maybe Double
geoLocationDist :: Maybe Double
, GeoLocation -> Maybe Integer
geoLocationHash :: Maybe Integer
, GeoLocation -> Maybe GeoCoordinates
geoLocationCoordinates :: Maybe GeoCoordinates
} deriving (Int -> GeoLocation -> ShowS
[GeoLocation] -> ShowS
GeoLocation -> String
(Int -> GeoLocation -> ShowS)
-> (GeoLocation -> String)
-> ([GeoLocation] -> ShowS)
-> Show GeoLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GeoLocation -> ShowS
showsPrec :: Int -> GeoLocation -> ShowS
$cshow :: GeoLocation -> String
show :: GeoLocation -> String
$cshowList :: [GeoLocation] -> ShowS
showList :: [GeoLocation] -> ShowS
Show, GeoLocation -> GeoLocation -> Bool
(GeoLocation -> GeoLocation -> Bool)
-> (GeoLocation -> GeoLocation -> Bool) -> Eq GeoLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GeoLocation -> GeoLocation -> Bool
== :: GeoLocation -> GeoLocation -> Bool
$c/= :: GeoLocation -> GeoLocation -> Bool
/= :: GeoLocation -> GeoLocation -> Bool
Eq)
instance RedisResult GeoLocation where
decode :: Reply -> Either Reply GeoLocation
decode r :: Reply
r@(Bulk (Just ByteString
_)) =
ByteString
-> Maybe Double
-> Maybe Integer
-> Maybe GeoCoordinates
-> GeoLocation
GeoLocation (ByteString
-> Maybe Double
-> Maybe Integer
-> Maybe GeoCoordinates
-> GeoLocation)
-> Either Reply ByteString
-> Either
Reply
(Maybe Double
-> Maybe Integer -> Maybe GeoCoordinates -> GeoLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
r Either
Reply
(Maybe Double
-> Maybe Integer -> Maybe GeoCoordinates -> GeoLocation)
-> Either Reply (Maybe Double)
-> Either
Reply (Maybe Integer -> Maybe GeoCoordinates -> GeoLocation)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Double -> Either Reply (Maybe Double)
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Double
forall a. Maybe a
Nothing Either Reply (Maybe Integer -> Maybe GeoCoordinates -> GeoLocation)
-> Either Reply (Maybe Integer)
-> Either Reply (Maybe GeoCoordinates -> GeoLocation)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Integer -> Either Reply (Maybe Integer)
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Integer
forall a. Maybe a
Nothing Either Reply (Maybe GeoCoordinates -> GeoLocation)
-> Either Reply (Maybe GeoCoordinates) -> Either Reply GeoLocation
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe GeoCoordinates -> Either Reply (Maybe GeoCoordinates)
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe GeoCoordinates
forall a. Maybe a
Nothing
decode r :: Reply
r@(SingleLine ByteString
_) =
ByteString
-> Maybe Double
-> Maybe Integer
-> Maybe GeoCoordinates
-> GeoLocation
GeoLocation (ByteString
-> Maybe Double
-> Maybe Integer
-> Maybe GeoCoordinates
-> GeoLocation)
-> Either Reply ByteString
-> Either
Reply
(Maybe Double
-> Maybe Integer -> Maybe GeoCoordinates -> GeoLocation)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
r Either
Reply
(Maybe Double
-> Maybe Integer -> Maybe GeoCoordinates -> GeoLocation)
-> Either Reply (Maybe Double)
-> Either
Reply (Maybe Integer -> Maybe GeoCoordinates -> GeoLocation)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Double -> Either Reply (Maybe Double)
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Double
forall a. Maybe a
Nothing Either Reply (Maybe Integer -> Maybe GeoCoordinates -> GeoLocation)
-> Either Reply (Maybe Integer)
-> Either Reply (Maybe GeoCoordinates -> GeoLocation)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe Integer -> Either Reply (Maybe Integer)
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Integer
forall a. Maybe a
Nothing Either Reply (Maybe GeoCoordinates -> GeoLocation)
-> Either Reply (Maybe GeoCoordinates) -> Either Reply GeoLocation
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe GeoCoordinates -> Either Reply (Maybe GeoCoordinates)
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe GeoCoordinates
forall a. Maybe a
Nothing
decode (MultiBulk (Just (Reply
memberReply:[Reply]
details))) = do
geoLocationMember <- Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
memberReply
(geoLocationDist, geoLocationHash, geoLocationCoordinates) <- decodeGeoLocationDetails details
pure GeoLocation {..}
where
decodeGeoLocationDetails :: [Reply] -> Either Reply (Maybe Double, Maybe Integer, Maybe GeoCoordinates)
decodeGeoLocationDetails :: [Reply]
-> Either Reply (Maybe Double, Maybe Integer, Maybe GeoCoordinates)
decodeGeoLocationDetails = Maybe Double
-> Maybe Integer
-> Maybe GeoCoordinates
-> [Reply]
-> Either Reply (Maybe Double, Maybe Integer, Maybe GeoCoordinates)
forall {a} {a} {a}.
(RedisResult a, RedisResult a, RedisResult a) =>
Maybe a
-> Maybe a
-> Maybe a
-> [Reply]
-> Either Reply (Maybe a, Maybe a, Maybe a)
go Maybe Double
forall a. Maybe a
Nothing Maybe Integer
forall a. Maybe a
Nothing Maybe GeoCoordinates
forall a. Maybe a
Nothing
go :: Maybe a
-> Maybe a
-> Maybe a
-> [Reply]
-> Either Reply (Maybe a, Maybe a, Maybe a)
go Maybe a
md Maybe a
mh Maybe a
mc [] = (Maybe a, Maybe a, Maybe a)
-> Either Reply (Maybe a, Maybe a, Maybe a)
forall a b. b -> Either a b
Right (Maybe a
md, Maybe a
mh, Maybe a
mc)
go Maybe a
md Maybe a
mh Maybe a
mc (Reply
x:[Reply]
xs) = case Reply
x of
MultiBulk Maybe [Reply]
_ -> do
coord <- Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
x
go md mh (Just coord) xs
Integer Integer
_ -> do
hashValue <- Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
x
go md (Just hashValue) mc xs
Reply
_ -> do
dist <- Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
x
go (Just dist) mh mc xs
decode Reply
r = Reply -> Either Reply GeoLocation
forall a b. a -> Either a b
Left Reply
r
data GeoSearchFrom
= GeoSearchFromMember ByteString
| GeoSearchFromLonLat Double Double
deriving (Int -> GeoSearchFrom -> ShowS
[GeoSearchFrom] -> ShowS
GeoSearchFrom -> String
(Int -> GeoSearchFrom -> ShowS)
-> (GeoSearchFrom -> String)
-> ([GeoSearchFrom] -> ShowS)
-> Show GeoSearchFrom
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GeoSearchFrom -> ShowS
showsPrec :: Int -> GeoSearchFrom -> ShowS
$cshow :: GeoSearchFrom -> String
show :: GeoSearchFrom -> String
$cshowList :: [GeoSearchFrom] -> ShowS
showList :: [GeoSearchFrom] -> ShowS
Show, GeoSearchFrom -> GeoSearchFrom -> Bool
(GeoSearchFrom -> GeoSearchFrom -> Bool)
-> (GeoSearchFrom -> GeoSearchFrom -> Bool) -> Eq GeoSearchFrom
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GeoSearchFrom -> GeoSearchFrom -> Bool
== :: GeoSearchFrom -> GeoSearchFrom -> Bool
$c/= :: GeoSearchFrom -> GeoSearchFrom -> Bool
/= :: GeoSearchFrom -> GeoSearchFrom -> Bool
Eq)
data GeoSearchBy
= GeoSearchByRadius Double GeoUnit
| GeoSearchByBox Double Double GeoUnit
deriving (Int -> GeoSearchBy -> ShowS
[GeoSearchBy] -> ShowS
GeoSearchBy -> String
(Int -> GeoSearchBy -> ShowS)
-> (GeoSearchBy -> String)
-> ([GeoSearchBy] -> ShowS)
-> Show GeoSearchBy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GeoSearchBy -> ShowS
showsPrec :: Int -> GeoSearchBy -> ShowS
$cshow :: GeoSearchBy -> String
show :: GeoSearchBy -> String
$cshowList :: [GeoSearchBy] -> ShowS
showList :: [GeoSearchBy] -> ShowS
Show, GeoSearchBy -> GeoSearchBy -> Bool
(GeoSearchBy -> GeoSearchBy -> Bool)
-> (GeoSearchBy -> GeoSearchBy -> Bool) -> Eq GeoSearchBy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GeoSearchBy -> GeoSearchBy -> Bool
== :: GeoSearchBy -> GeoSearchBy -> Bool
$c/= :: GeoSearchBy -> GeoSearchBy -> Bool
/= :: GeoSearchBy -> GeoSearchBy -> Bool
Eq)
data GeoSearchOpts = GeoSearchOpts
{ GeoSearchOpts -> Bool
geoSearchWithCoord :: Bool
, GeoSearchOpts -> Bool
geoSearchWithDist :: Bool
, GeoSearchOpts -> Bool
geoSearchWithHash :: Bool
, GeoSearchOpts -> Maybe Integer
geoSearchCount :: Maybe Integer
, GeoSearchOpts -> Bool
geoSearchCountAny :: Bool
, GeoSearchOpts -> Maybe GeoOrder
geoSearchOrder :: Maybe GeoOrder
} deriving (Int -> GeoSearchOpts -> ShowS
[GeoSearchOpts] -> ShowS
GeoSearchOpts -> String
(Int -> GeoSearchOpts -> ShowS)
-> (GeoSearchOpts -> String)
-> ([GeoSearchOpts] -> ShowS)
-> Show GeoSearchOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GeoSearchOpts -> ShowS
showsPrec :: Int -> GeoSearchOpts -> ShowS
$cshow :: GeoSearchOpts -> String
show :: GeoSearchOpts -> String
$cshowList :: [GeoSearchOpts] -> ShowS
showList :: [GeoSearchOpts] -> ShowS
Show, GeoSearchOpts -> GeoSearchOpts -> Bool
(GeoSearchOpts -> GeoSearchOpts -> Bool)
-> (GeoSearchOpts -> GeoSearchOpts -> Bool) -> Eq GeoSearchOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GeoSearchOpts -> GeoSearchOpts -> Bool
== :: GeoSearchOpts -> GeoSearchOpts -> Bool
$c/= :: GeoSearchOpts -> GeoSearchOpts -> Bool
/= :: GeoSearchOpts -> GeoSearchOpts -> Bool
Eq)
defaultGeoSearchOpts :: GeoSearchOpts
defaultGeoSearchOpts :: GeoSearchOpts
defaultGeoSearchOpts = GeoSearchOpts
{ geoSearchWithCoord :: Bool
geoSearchWithCoord = Bool
False
, geoSearchWithDist :: Bool
geoSearchWithDist = Bool
False
, geoSearchWithHash :: Bool
geoSearchWithHash = Bool
False
, geoSearchCount :: Maybe Integer
geoSearchCount = Maybe Integer
forall a. Maybe a
Nothing
, geoSearchCountAny :: Bool
geoSearchCountAny = Bool
False
, geoSearchOrder :: Maybe GeoOrder
geoSearchOrder = Maybe GeoOrder
forall a. Maybe a
Nothing
}
data GeoSearchStoreOpts = GeoSearchStoreOpts
{ GeoSearchStoreOpts -> Maybe Integer
geoSearchStoreCount :: Maybe Integer
, GeoSearchStoreOpts -> Bool
geoSearchStoreCountAny :: Bool
, GeoSearchStoreOpts -> Maybe GeoOrder
geoSearchStoreOrder :: Maybe GeoOrder
, GeoSearchStoreOpts -> Bool
geoSearchStoreStoredist :: Bool
} deriving (Int -> GeoSearchStoreOpts -> ShowS
[GeoSearchStoreOpts] -> ShowS
GeoSearchStoreOpts -> String
(Int -> GeoSearchStoreOpts -> ShowS)
-> (GeoSearchStoreOpts -> String)
-> ([GeoSearchStoreOpts] -> ShowS)
-> Show GeoSearchStoreOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GeoSearchStoreOpts -> ShowS
showsPrec :: Int -> GeoSearchStoreOpts -> ShowS
$cshow :: GeoSearchStoreOpts -> String
show :: GeoSearchStoreOpts -> String
$cshowList :: [GeoSearchStoreOpts] -> ShowS
showList :: [GeoSearchStoreOpts] -> ShowS
Show, GeoSearchStoreOpts -> GeoSearchStoreOpts -> Bool
(GeoSearchStoreOpts -> GeoSearchStoreOpts -> Bool)
-> (GeoSearchStoreOpts -> GeoSearchStoreOpts -> Bool)
-> Eq GeoSearchStoreOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GeoSearchStoreOpts -> GeoSearchStoreOpts -> Bool
== :: GeoSearchStoreOpts -> GeoSearchStoreOpts -> Bool
$c/= :: GeoSearchStoreOpts -> GeoSearchStoreOpts -> Bool
/= :: GeoSearchStoreOpts -> GeoSearchStoreOpts -> Bool
Eq)
defaultGeoSearchStoreOpts :: GeoSearchStoreOpts
defaultGeoSearchStoreOpts :: GeoSearchStoreOpts
defaultGeoSearchStoreOpts = GeoSearchStoreOpts
{ geoSearchStoreCount :: Maybe Integer
geoSearchStoreCount = Maybe Integer
forall a. Maybe a
Nothing
, geoSearchStoreCountAny :: Bool
geoSearchStoreCountAny = Bool
False
, geoSearchStoreOrder :: Maybe GeoOrder
geoSearchStoreOrder = Maybe GeoOrder
forall a. Maybe a
Nothing
, geoSearchStoreStoredist :: Bool
geoSearchStoreStoredist = Bool
False
}
data GeoAddOpts = GeoAddOpts
{ GeoAddOpts -> Maybe Condition
geoAddCondition :: Maybe Condition
, GeoAddOpts -> Bool
geoAddChange :: Bool
} deriving (Int -> GeoAddOpts -> ShowS
[GeoAddOpts] -> ShowS
GeoAddOpts -> String
(Int -> GeoAddOpts -> ShowS)
-> (GeoAddOpts -> String)
-> ([GeoAddOpts] -> ShowS)
-> Show GeoAddOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GeoAddOpts -> ShowS
showsPrec :: Int -> GeoAddOpts -> ShowS
$cshow :: GeoAddOpts -> String
show :: GeoAddOpts -> String
$cshowList :: [GeoAddOpts] -> ShowS
showList :: [GeoAddOpts] -> ShowS
Show, GeoAddOpts -> GeoAddOpts -> Bool
(GeoAddOpts -> GeoAddOpts -> Bool)
-> (GeoAddOpts -> GeoAddOpts -> Bool) -> Eq GeoAddOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GeoAddOpts -> GeoAddOpts -> Bool
== :: GeoAddOpts -> GeoAddOpts -> Bool
$c/= :: GeoAddOpts -> GeoAddOpts -> Bool
/= :: GeoAddOpts -> GeoAddOpts -> Bool
Eq)
defaultGeoAddOpts :: GeoAddOpts
defaultGeoAddOpts :: GeoAddOpts
defaultGeoAddOpts = GeoAddOpts
{ geoAddCondition :: Maybe Condition
geoAddCondition = Maybe Condition
forall a. Maybe a
Nothing
, geoAddChange :: Bool
geoAddChange = Bool
False
}
geoadd
:: (RedisCtx m f)
=> ByteString
-> [(Double, Double, ByteString)]
-> m (f Integer)
geoadd :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [(Double, Double, ByteString)] -> m (f Integer)
geoadd ByteString
key [(Double, Double, ByteString)]
values = ByteString
-> [(Double, Double, ByteString)] -> GeoAddOpts -> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> [(Double, Double, ByteString)] -> GeoAddOpts -> m (f Integer)
geoaddOpts ByteString
key [(Double, Double, ByteString)]
values GeoAddOpts
defaultGeoAddOpts
geoaddOpts
:: (RedisCtx m f)
=> ByteString
-> [(Double, Double, ByteString)]
-> GeoAddOpts
-> m (f Integer)
geoaddOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> [(Double, Double, ByteString)] -> GeoAddOpts -> m (f Integer)
geoaddOpts ByteString
key [(Double, Double, ByteString)]
values GeoAddOpts{Bool
Maybe Condition
geoAddCondition :: GeoAddOpts -> Maybe Condition
geoAddChange :: GeoAddOpts -> Bool
geoAddCondition :: Maybe Condition
geoAddChange :: Bool
..} =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"GEOADD", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
conditionArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
changeArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ((Double, Double, ByteString) -> [ByteString])
-> [(Double, Double, ByteString)] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (Double, Double, ByteString) -> [ByteString]
forall {a} {a}.
(RedisArg a, RedisArg a) =>
(a, a, ByteString) -> [ByteString]
encodeGeoValue [(Double, Double, ByteString)]
values
where
conditionArg :: [ByteString]
conditionArg = (Condition -> [ByteString]) -> Maybe Condition -> [ByteString]
forall m a. Monoid m => (a -> m) -> Maybe a -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (\Condition
condition -> [Condition -> ByteString
forall a. RedisArg a => a -> ByteString
encode Condition
condition]) Maybe Condition
geoAddCondition
changeArg :: [ByteString]
changeArg = [ByteString
"CH" | Bool
geoAddChange]
encodeGeoValue :: (a, a, ByteString) -> [ByteString]
encodeGeoValue (a
lon, a
lat, ByteString
member) = [a -> ByteString
forall a. RedisArg a => a -> ByteString
encode a
lon, a -> ByteString
forall a. RedisArg a => a -> ByteString
encode a
lat, ByteString
member]
geodist
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> Maybe GeoUnit
-> m (f (Maybe Double))
geodist :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> Maybe GeoUnit
-> m (f (Maybe Double))
geodist ByteString
key ByteString
member1 ByteString
member2 Maybe GeoUnit
munit =
[ByteString] -> m (f (Maybe Double))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe Double)))
-> [ByteString] -> m (f (Maybe Double))
forall a b. (a -> b) -> a -> b
$ [ByteString
"GEODIST", ByteString
key, ByteString
member1, ByteString
member2] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ Maybe ByteString -> [ByteString]
forall a. Maybe a -> [a]
maybeToList (GeoUnit -> ByteString
forall a. RedisArg a => a -> ByteString
encode (GeoUnit -> ByteString) -> Maybe GeoUnit -> Maybe ByteString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe GeoUnit
munit)
geopos
:: (RedisCtx m f)
=> ByteString
-> [ByteString]
-> m (f [Maybe GeoCoordinates])
geopos :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> [ByteString] -> m (f [Maybe GeoCoordinates])
geopos ByteString
key [ByteString]
members = [ByteString] -> m (f [Maybe GeoCoordinates])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [Maybe GeoCoordinates]))
-> [ByteString] -> m (f [Maybe GeoCoordinates])
forall a b. (a -> b) -> a -> b
$ [ByteString
"GEOPOS", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
members
geoSearch
:: (RedisCtx m f)
=> ByteString
-> GeoSearchFrom
-> GeoSearchBy
-> GeoSearchOpts
-> m (f [GeoLocation])
geoSearch :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> GeoSearchFrom
-> GeoSearchBy
-> GeoSearchOpts
-> m (f [GeoLocation])
geoSearch ByteString
key GeoSearchFrom
from GeoSearchBy
by GeoSearchOpts
opts =
[ByteString] -> m (f [GeoLocation])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [GeoLocation]))
-> [ByteString] -> m (f [GeoLocation])
forall a b. (a -> b) -> a -> b
$ [ByteString
"GEOSEARCH", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ GeoSearchFrom -> [ByteString]
geoSearchFromArgs GeoSearchFrom
from [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ GeoSearchBy -> [ByteString]
geoSearchByArgs GeoSearchBy
by [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ GeoSearchOpts -> [ByteString]
geoSearchOptsArgs GeoSearchOpts
opts
geoSearchStore
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> GeoSearchFrom
-> GeoSearchBy
-> GeoSearchStoreOpts
-> m (f Integer)
geoSearchStore :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> GeoSearchFrom
-> GeoSearchBy
-> GeoSearchStoreOpts
-> m (f Integer)
geoSearchStore ByteString
destination ByteString
source GeoSearchFrom
from GeoSearchBy
by GeoSearchStoreOpts
opts =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"GEOSEARCHSTORE", ByteString
destination, ByteString
source] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ GeoSearchFrom -> [ByteString]
geoSearchFromArgs GeoSearchFrom
from [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ GeoSearchBy -> [ByteString]
geoSearchByArgs GeoSearchBy
by [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ GeoSearchStoreOpts -> [ByteString]
geoSearchStoreOptsArgs GeoSearchStoreOpts
opts
geoSearchFromArgs :: GeoSearchFrom -> [ByteString]
geoSearchFromArgs :: GeoSearchFrom -> [ByteString]
geoSearchFromArgs (GeoSearchFromMember ByteString
member) = [ByteString
"FROMMEMBER", ByteString
member]
geoSearchFromArgs (GeoSearchFromLonLat Double
lon Double
lat) = [ByteString
"FROMLONLAT", Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
lon, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
lat]
geoSearchByArgs :: GeoSearchBy -> [ByteString]
geoSearchByArgs :: GeoSearchBy -> [ByteString]
geoSearchByArgs (GeoSearchByRadius Double
radius GeoUnit
unit) = [ByteString
"BYRADIUS", Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
radius, GeoUnit -> ByteString
forall a. RedisArg a => a -> ByteString
encode GeoUnit
unit]
geoSearchByArgs (GeoSearchByBox Double
width Double
height GeoUnit
unit) = [ByteString
"BYBOX", Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
width, Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
height, GeoUnit -> ByteString
forall a. RedisArg a => a -> ByteString
encode GeoUnit
unit]
geoSearchOptsArgs :: GeoSearchOpts -> [ByteString]
geoSearchOptsArgs :: GeoSearchOpts -> [ByteString]
geoSearchOptsArgs GeoSearchOpts{Bool
Maybe Integer
Maybe GeoOrder
geoSearchWithCoord :: GeoSearchOpts -> Bool
geoSearchWithDist :: GeoSearchOpts -> Bool
geoSearchWithHash :: GeoSearchOpts -> Bool
geoSearchCount :: GeoSearchOpts -> Maybe Integer
geoSearchCountAny :: GeoSearchOpts -> Bool
geoSearchOrder :: GeoSearchOpts -> Maybe GeoOrder
geoSearchWithCoord :: Bool
geoSearchWithDist :: Bool
geoSearchWithHash :: Bool
geoSearchCount :: Maybe Integer
geoSearchCountAny :: Bool
geoSearchOrder :: Maybe GeoOrder
..} =
[ByteString]
orderArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
countArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
withCoord [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
withDist [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
withHash
where
orderArg :: [ByteString]
orderArg = [ByteString]
-> (GeoOrder -> [ByteString]) -> Maybe GeoOrder -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\GeoOrder
order -> [GeoOrder -> ByteString
forall a. RedisArg a => a -> ByteString
encode GeoOrder
order]) Maybe GeoOrder
geoSearchOrder
countArg :: [ByteString]
countArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
count -> [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"ANY" | Bool
geoSearchCountAny]) Maybe Integer
geoSearchCount
withCoord :: [ByteString]
withCoord = [ByteString
"WITHCOORD" | Bool
geoSearchWithCoord]
withDist :: [ByteString]
withDist = [ByteString
"WITHDIST" | Bool
geoSearchWithDist]
withHash :: [ByteString]
withHash = [ByteString
"WITHHASH" | Bool
geoSearchWithHash]
geoSearchStoreOptsArgs :: GeoSearchStoreOpts -> [ByteString]
geoSearchStoreOptsArgs :: GeoSearchStoreOpts -> [ByteString]
geoSearchStoreOptsArgs GeoSearchStoreOpts{Bool
Maybe Integer
Maybe GeoOrder
geoSearchStoreCount :: GeoSearchStoreOpts -> Maybe Integer
geoSearchStoreCountAny :: GeoSearchStoreOpts -> Bool
geoSearchStoreOrder :: GeoSearchStoreOpts -> Maybe GeoOrder
geoSearchStoreStoredist :: GeoSearchStoreOpts -> Bool
geoSearchStoreCount :: Maybe Integer
geoSearchStoreCountAny :: Bool
geoSearchStoreOrder :: Maybe GeoOrder
geoSearchStoreStoredist :: Bool
..} =
[ByteString]
orderArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
countArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
storeDistArg
where
orderArg :: [ByteString]
orderArg = [ByteString]
-> (GeoOrder -> [ByteString]) -> Maybe GeoOrder -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\GeoOrder
order -> [GeoOrder -> ByteString
forall a. RedisArg a => a -> ByteString
encode GeoOrder
order]) Maybe GeoOrder
geoSearchStoreOrder
countArg :: [ByteString]
countArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
count -> [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"ANY" | Bool
geoSearchStoreCountAny]) Maybe Integer
geoSearchStoreCount
storeDistArg :: [ByteString]
storeDistArg = [ByteString
"STOREDIST" | Bool
geoSearchStoreStoredist]
data XInfoConsumersResponse = XInfoConsumersResponse
{ XInfoConsumersResponse -> ByteString
xinfoConsumerName :: ByteString
, XInfoConsumersResponse -> Integer
xinfoConsumerNumPendingMessages :: Integer
, XInfoConsumersResponse -> Integer
xinfoConsumerIdleTime :: Integer
, XInfoConsumersResponse -> Maybe Integer
xinfoConsumerInactive :: Maybe Integer
} deriving (Int -> XInfoConsumersResponse -> ShowS
[XInfoConsumersResponse] -> ShowS
XInfoConsumersResponse -> String
(Int -> XInfoConsumersResponse -> ShowS)
-> (XInfoConsumersResponse -> String)
-> ([XInfoConsumersResponse] -> ShowS)
-> Show XInfoConsumersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XInfoConsumersResponse -> ShowS
showsPrec :: Int -> XInfoConsumersResponse -> ShowS
$cshow :: XInfoConsumersResponse -> String
show :: XInfoConsumersResponse -> String
$cshowList :: [XInfoConsumersResponse] -> ShowS
showList :: [XInfoConsumersResponse] -> ShowS
Show, XInfoConsumersResponse -> XInfoConsumersResponse -> Bool
(XInfoConsumersResponse -> XInfoConsumersResponse -> Bool)
-> (XInfoConsumersResponse -> XInfoConsumersResponse -> Bool)
-> Eq XInfoConsumersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XInfoConsumersResponse -> XInfoConsumersResponse -> Bool
== :: XInfoConsumersResponse -> XInfoConsumersResponse -> Bool
$c/= :: XInfoConsumersResponse -> XInfoConsumersResponse -> Bool
/= :: XInfoConsumersResponse -> XInfoConsumersResponse -> Bool
Eq)
instance RedisResult XInfoConsumersResponse where
decode :: Reply -> Either Reply XInfoConsumersResponse
decode = Reply -> Either Reply XInfoConsumersResponse
decodeRedis6 (Reply -> Either Reply XInfoConsumersResponse)
-> (Reply -> Either Reply XInfoConsumersResponse)
-> Reply
-> Either Reply XInfoConsumersResponse
forall a. Semigroup a => a -> a -> a
<> Reply -> Either Reply XInfoConsumersResponse
decodeRedis7
where decodeRedis6 :: Reply -> Either Reply XInfoConsumersResponse
decodeRedis6 (MultiBulk (Just [
Bulk (Just ByteString
"name"),
Bulk (Just ByteString
xinfoConsumerName),
Bulk (Just ByteString
"pending"),
Integer Integer
xinfoConsumerNumPendingMessages,
Bulk (Just ByteString
"idle"),
Integer Integer
xinfoConsumerIdleTime])) = XInfoConsumersResponse -> Either Reply XInfoConsumersResponse
forall a b. b -> Either a b
Right XInfoConsumersResponse{xinfoConsumerInactive :: Maybe Integer
xinfoConsumerInactive = Maybe Integer
forall a. Maybe a
Nothing, Integer
ByteString
xinfoConsumerName :: ByteString
xinfoConsumerNumPendingMessages :: Integer
xinfoConsumerIdleTime :: Integer
xinfoConsumerName :: ByteString
xinfoConsumerNumPendingMessages :: Integer
xinfoConsumerIdleTime :: Integer
..}
decodeRedis6 Reply
a = Reply -> Either Reply XInfoConsumersResponse
forall a b. a -> Either a b
Left Reply
a
decodeRedis7 :: Reply -> Either Reply XInfoConsumersResponse
decodeRedis7 (MultiBulk (Just [
Bulk (Just ByteString
"name"),
Bulk (Just ByteString
xinfoConsumerName),
Bulk (Just ByteString
"pending"),
Integer Integer
xinfoConsumerNumPendingMessages,
Bulk (Just ByteString
"idle"),
Integer Integer
xinfoConsumerIdleTime,
Bulk (Just ByteString
"inactive"),
Integer Integer
xinfoConsumerInactive])) = XInfoConsumersResponse -> Either Reply XInfoConsumersResponse
forall a b. b -> Either a b
Right XInfoConsumersResponse{xinfoConsumerInactive :: Maybe Integer
xinfoConsumerInactive = Integer -> Maybe Integer
forall a. a -> Maybe a
Just Integer
xinfoConsumerInactive, Integer
ByteString
xinfoConsumerName :: ByteString
xinfoConsumerNumPendingMessages :: Integer
xinfoConsumerIdleTime :: Integer
xinfoConsumerName :: ByteString
xinfoConsumerNumPendingMessages :: Integer
xinfoConsumerIdleTime :: Integer
..}
decodeRedis7 Reply
a = Reply -> Either Reply XInfoConsumersResponse
forall a b. a -> Either a b
Left Reply
a
xinfoConsumers
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> m (f [XInfoConsumersResponse])
xinfoConsumers :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> ByteString -> m (f [XInfoConsumersResponse])
xinfoConsumers ByteString
stream ByteString
group = [ByteString] -> m (f [XInfoConsumersResponse])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [XInfoConsumersResponse]))
-> [ByteString] -> m (f [XInfoConsumersResponse])
forall a b. (a -> b) -> a -> b
$ [ByteString
"XINFO", ByteString
"CONSUMERS", ByteString
stream, ByteString
group]
data XInfoGroupsResponse = XInfoGroupsResponse
{ XInfoGroupsResponse -> ByteString
xinfoGroupsGroupName :: ByteString
, XInfoGroupsResponse -> Integer
xinfoGroupsNumConsumers :: Integer
, XInfoGroupsResponse -> Integer
xinfoGroupsNumPendingMessages :: Integer
, XInfoGroupsResponse -> ByteString
xinfoGroupsLastDeliveredMessageId :: ByteString
, XInfoGroupsResponse -> Maybe Integer
xinfoGroupsEntriesRead :: Maybe Integer
, XInfoGroupsResponse -> Maybe Integer
xinfoGroupsLag :: Maybe Integer
} deriving (Int -> XInfoGroupsResponse -> ShowS
[XInfoGroupsResponse] -> ShowS
XInfoGroupsResponse -> String
(Int -> XInfoGroupsResponse -> ShowS)
-> (XInfoGroupsResponse -> String)
-> ([XInfoGroupsResponse] -> ShowS)
-> Show XInfoGroupsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XInfoGroupsResponse -> ShowS
showsPrec :: Int -> XInfoGroupsResponse -> ShowS
$cshow :: XInfoGroupsResponse -> String
show :: XInfoGroupsResponse -> String
$cshowList :: [XInfoGroupsResponse] -> ShowS
showList :: [XInfoGroupsResponse] -> ShowS
Show, XInfoGroupsResponse -> XInfoGroupsResponse -> Bool
(XInfoGroupsResponse -> XInfoGroupsResponse -> Bool)
-> (XInfoGroupsResponse -> XInfoGroupsResponse -> Bool)
-> Eq XInfoGroupsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XInfoGroupsResponse -> XInfoGroupsResponse -> Bool
== :: XInfoGroupsResponse -> XInfoGroupsResponse -> Bool
$c/= :: XInfoGroupsResponse -> XInfoGroupsResponse -> Bool
/= :: XInfoGroupsResponse -> XInfoGroupsResponse -> Bool
Eq)
instance RedisResult XInfoGroupsResponse where
decode :: Reply -> Either Reply XInfoGroupsResponse
decode = Reply -> Either Reply XInfoGroupsResponse
decodeRedis6 (Reply -> Either Reply XInfoGroupsResponse)
-> (Reply -> Either Reply XInfoGroupsResponse)
-> Reply
-> Either Reply XInfoGroupsResponse
forall a. Semigroup a => a -> a -> a
<> Reply -> Either Reply XInfoGroupsResponse
decodeRedis7
where decodeRedis6 :: Reply -> Either Reply XInfoGroupsResponse
decodeRedis6 (MultiBulk (Just [
Bulk (Just ByteString
"name"), Bulk (Just ByteString
xinfoGroupsGroupName),
Bulk (Just ByteString
"consumers"), Integer Integer
xinfoGroupsNumConsumers,
Bulk (Just ByteString
"pending"), Integer Integer
xinfoGroupsNumPendingMessages,
Bulk (Just ByteString
"last-delivered-id"),
Bulk (Just ByteString
xinfoGroupsLastDeliveredMessageId)])) =
XInfoGroupsResponse -> Either Reply XInfoGroupsResponse
forall a b. b -> Either a b
Right XInfoGroupsResponse{
xinfoGroupsEntriesRead :: Maybe Integer
xinfoGroupsEntriesRead = Maybe Integer
forall a. Maybe a
Nothing
, xinfoGroupsLag :: Maybe Integer
xinfoGroupsLag = Maybe Integer
forall a. Maybe a
Nothing
, Integer
ByteString
xinfoGroupsGroupName :: ByteString
xinfoGroupsNumConsumers :: Integer
xinfoGroupsNumPendingMessages :: Integer
xinfoGroupsLastDeliveredMessageId :: ByteString
xinfoGroupsGroupName :: ByteString
xinfoGroupsNumConsumers :: Integer
xinfoGroupsNumPendingMessages :: Integer
xinfoGroupsLastDeliveredMessageId :: ByteString
..}
decodeRedis6 Reply
a = Reply -> Either Reply XInfoGroupsResponse
forall a b. a -> Either a b
Left Reply
a
decodeRedis7 :: Reply -> Either Reply XInfoGroupsResponse
decodeRedis7 (MultiBulk (Just [
Bulk (Just ByteString
"name"), Bulk (Just ByteString
xinfoGroupsGroupName),
Bulk (Just ByteString
"consumers"), Integer Integer
xinfoGroupsNumConsumers,
Bulk (Just ByteString
"pending"), Integer Integer
xinfoGroupsNumPendingMessages,
Bulk (Just ByteString
"last-delivered-id"), Bulk (Just ByteString
xinfoGroupsLastDeliveredMessageId),
Bulk (Just ByteString
"entries-read"), Integer Integer
xinfoGroupsEntriesRead,
Bulk (Just ByteString
"lag"), Integer Integer
xinfoGroupsLag])) =
XInfoGroupsResponse -> Either Reply XInfoGroupsResponse
forall a b. b -> Either a b
Right XInfoGroupsResponse{
xinfoGroupsEntriesRead :: Maybe Integer
xinfoGroupsEntriesRead = Integer -> Maybe Integer
forall a. a -> Maybe a
Just Integer
xinfoGroupsEntriesRead
, xinfoGroupsLag :: Maybe Integer
xinfoGroupsLag = Integer -> Maybe Integer
forall a. a -> Maybe a
Just Integer
xinfoGroupsLag
, Integer
ByteString
xinfoGroupsGroupName :: ByteString
xinfoGroupsNumConsumers :: Integer
xinfoGroupsNumPendingMessages :: Integer
xinfoGroupsLastDeliveredMessageId :: ByteString
xinfoGroupsGroupName :: ByteString
xinfoGroupsNumConsumers :: Integer
xinfoGroupsNumPendingMessages :: Integer
xinfoGroupsLastDeliveredMessageId :: ByteString
..}
decodeRedis7 Reply
a = Reply -> Either Reply XInfoGroupsResponse
forall a b. a -> Either a b
Left Reply
a
xinfoGroups
:: (RedisCtx m f)
=> ByteString
-> m (f [XInfoGroupsResponse])
xinfoGroups :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f [XInfoGroupsResponse])
xinfoGroups ByteString
stream = [ByteString] -> m (f [XInfoGroupsResponse])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"XINFO", ByteString
"GROUPS", ByteString
stream]
data XInfoStreamResponse
= XInfoStreamResponse
{ XInfoStreamResponse -> Integer
xinfoStreamLength :: Integer
, XInfoStreamResponse -> Integer
xinfoStreamRadixTreeKeys :: Integer
, XInfoStreamResponse -> Integer
xinfoStreamRadixTreeNodes :: Integer
, XInfoStreamResponse -> Maybe ByteString
xinfoMaxDeletedEntryId :: Maybe ByteString
, XInfoStreamResponse -> Maybe Integer
xinfoEntriesAdded :: Maybe Integer
, XInfoStreamResponse -> Maybe ByteString
xinfoRecordedFirstEntryId :: Maybe ByteString
, XInfoStreamResponse -> Integer
xinfoStreamNumGroups :: Integer
, XInfoStreamResponse -> ByteString
xinfoStreamLastEntryId :: ByteString
, XInfoStreamResponse -> StreamsRecord
xinfoStreamFirstEntry :: StreamsRecord
, XInfoStreamResponse -> StreamsRecord
xinfoStreamLastEntry :: StreamsRecord
}
| XInfoStreamEmptyResponse
{ xinfoStreamLength :: Integer
, xinfoStreamRadixTreeKeys :: Integer
, xinfoStreamRadixTreeNodes :: Integer
, xinfoMaxDeletedEntryId :: Maybe ByteString
, xinfoEntriesAdded :: Maybe Integer
, xinfoRecordedFirstEntryId :: Maybe ByteString
, xinfoStreamNumGroups :: Integer
, xinfoStreamLastEntryId :: ByteString
}
deriving (Int -> XInfoStreamResponse -> ShowS
[XInfoStreamResponse] -> ShowS
XInfoStreamResponse -> String
(Int -> XInfoStreamResponse -> ShowS)
-> (XInfoStreamResponse -> String)
-> ([XInfoStreamResponse] -> ShowS)
-> Show XInfoStreamResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XInfoStreamResponse -> ShowS
showsPrec :: Int -> XInfoStreamResponse -> ShowS
$cshow :: XInfoStreamResponse -> String
show :: XInfoStreamResponse -> String
$cshowList :: [XInfoStreamResponse] -> ShowS
showList :: [XInfoStreamResponse] -> ShowS
Show, XInfoStreamResponse -> XInfoStreamResponse -> Bool
(XInfoStreamResponse -> XInfoStreamResponse -> Bool)
-> (XInfoStreamResponse -> XInfoStreamResponse -> Bool)
-> Eq XInfoStreamResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XInfoStreamResponse -> XInfoStreamResponse -> Bool
== :: XInfoStreamResponse -> XInfoStreamResponse -> Bool
$c/= :: XInfoStreamResponse -> XInfoStreamResponse -> Bool
/= :: XInfoStreamResponse -> XInfoStreamResponse -> Bool
Eq)
instance RedisResult XInfoStreamResponse where
decode :: Reply -> Either Reply XInfoStreamResponse
decode = Reply -> Either Reply XInfoStreamResponse
decodeRedis5 (Reply -> Either Reply XInfoStreamResponse)
-> (Reply -> Either Reply XInfoStreamResponse)
-> Reply
-> Either Reply XInfoStreamResponse
forall a. Semigroup a => a -> a -> a
<> Reply -> Either Reply XInfoStreamResponse
decodeRedis6 (Reply -> Either Reply XInfoStreamResponse)
-> (Reply -> Either Reply XInfoStreamResponse)
-> Reply
-> Either Reply XInfoStreamResponse
forall a. Semigroup a => a -> a -> a
<> Reply -> Either Reply XInfoStreamResponse
decodeRedis7
where
decodeRedis5 :: Reply -> Either Reply XInfoStreamResponse
decodeRedis5 (MultiBulk (Just [
Bulk (Just ByteString
"length"), Integer Integer
xinfoStreamLength,
Bulk (Just ByteString
"radix-tree-keys"), Integer Integer
xinfoStreamRadixTreeKeys,
Bulk (Just ByteString
"radix-tree-nodes"), Integer Integer
xinfoStreamRadixTreeNodes,
Bulk (Just ByteString
"groups"), Integer Integer
xinfoStreamNumGroups,
Bulk (Just ByteString
"last-generated-id"), Bulk (Just ByteString
xinfoStreamLastEntryId),
Bulk (Just ByteString
"first-entry"), Bulk Maybe ByteString
Nothing ,
Bulk (Just ByteString
"last-entry"), Bulk Maybe ByteString
Nothing ])) = do
XInfoStreamResponse -> Either Reply XInfoStreamResponse
forall a. a -> Either Reply a
forall (m :: * -> *) a. Monad m => a -> m a
return XInfoStreamEmptyResponse{
xinfoMaxDeletedEntryId :: Maybe ByteString
xinfoMaxDeletedEntryId = Maybe ByteString
forall a. Maybe a
Nothing
, xinfoEntriesAdded :: Maybe Integer
xinfoEntriesAdded = Maybe Integer
forall a. Maybe a
Nothing
, xinfoRecordedFirstEntryId :: Maybe ByteString
xinfoRecordedFirstEntryId = Maybe ByteString
forall a. Maybe a
Nothing
, Integer
ByteString
xinfoStreamLength :: Integer
xinfoStreamRadixTreeKeys :: Integer
xinfoStreamRadixTreeNodes :: Integer
xinfoStreamNumGroups :: Integer
xinfoStreamLastEntryId :: ByteString
xinfoStreamLength :: Integer
xinfoStreamRadixTreeKeys :: Integer
xinfoStreamRadixTreeNodes :: Integer
xinfoStreamNumGroups :: Integer
xinfoStreamLastEntryId :: ByteString
..}
decodeRedis5 (MultiBulk (Just [
Bulk (Just ByteString
"length"), Integer Integer
xinfoStreamLength,
Bulk (Just ByteString
"radix-tree-keys"), Integer Integer
xinfoStreamRadixTreeKeys,
Bulk (Just ByteString
"radix-tree-nodes"), Integer Integer
xinfoStreamRadixTreeNodes,
Bulk (Just ByteString
"groups"), Integer Integer
xinfoStreamNumGroups,
Bulk (Just ByteString
"last-generated-id"), Bulk (Just ByteString
xinfoStreamLastEntryId),
Bulk (Just ByteString
"first-entry"), Reply
rawFirstEntry ,
Bulk (Just ByteString
"last-entry"), Reply
rawLastEntry ])) = do
xinfoStreamFirstEntry <- Reply -> Either Reply StreamsRecord
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
rawFirstEntry
xinfoStreamLastEntry <- decode rawLastEntry
return XInfoStreamResponse{
xinfoMaxDeletedEntryId = Nothing
, xinfoEntriesAdded = Nothing
, xinfoRecordedFirstEntryId = Nothing
, ..}
decodeRedis5 Reply
a = Reply -> Either Reply XInfoStreamResponse
forall a b. a -> Either a b
Left Reply
a
decodeRedis6 :: Reply -> Either Reply XInfoStreamResponse
decodeRedis6 (MultiBulk (Just [
Bulk (Just ByteString
"length"), Integer Integer
xinfoStreamLength,
Bulk (Just ByteString
"radix-tree-keys"), Integer Integer
xinfoStreamRadixTreeKeys,
Bulk (Just ByteString
"radix-tree-nodes"), Integer Integer
xinfoStreamRadixTreeNodes,
Bulk (Just ByteString
"last-generated-id"), Bulk (Just ByteString
xinfoStreamLastEntryId),
Bulk (Just ByteString
"groups"), Integer Integer
xinfoStreamNumGroups,
Bulk (Just ByteString
"first-entry"), Bulk Maybe ByteString
Nothing ,
Bulk (Just ByteString
"last-entry"), Bulk Maybe ByteString
Nothing ])) = do
XInfoStreamResponse -> Either Reply XInfoStreamResponse
forall a. a -> Either Reply a
forall (m :: * -> *) a. Monad m => a -> m a
return XInfoStreamEmptyResponse{
xinfoMaxDeletedEntryId :: Maybe ByteString
xinfoMaxDeletedEntryId = Maybe ByteString
forall a. Maybe a
Nothing
, xinfoEntriesAdded :: Maybe Integer
xinfoEntriesAdded = Maybe Integer
forall a. Maybe a
Nothing
, xinfoRecordedFirstEntryId :: Maybe ByteString
xinfoRecordedFirstEntryId = Maybe ByteString
forall a. Maybe a
Nothing
, Integer
ByteString
xinfoStreamLength :: Integer
xinfoStreamRadixTreeKeys :: Integer
xinfoStreamRadixTreeNodes :: Integer
xinfoStreamNumGroups :: Integer
xinfoStreamLastEntryId :: ByteString
xinfoStreamLength :: Integer
xinfoStreamRadixTreeKeys :: Integer
xinfoStreamRadixTreeNodes :: Integer
xinfoStreamLastEntryId :: ByteString
xinfoStreamNumGroups :: Integer
..}
decodeRedis6 (MultiBulk (Just [
Bulk (Just ByteString
"length"), Integer Integer
xinfoStreamLength,
Bulk (Just ByteString
"radix-tree-keys"), Integer Integer
xinfoStreamRadixTreeKeys,
Bulk (Just ByteString
"radix-tree-nodes"), Integer Integer
xinfoStreamRadixTreeNodes,
Bulk (Just ByteString
"last-generated-id"), Bulk (Just ByteString
xinfoStreamLastEntryId),
Bulk (Just ByteString
"groups"), Integer Integer
xinfoStreamNumGroups,
Bulk (Just ByteString
"first-entry"), Reply
rawFirstEntry ,
Bulk (Just ByteString
"last-entry"), Reply
rawLastEntry ])) = do
xinfoStreamFirstEntry <- Reply -> Either Reply StreamsRecord
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
rawFirstEntry
xinfoStreamLastEntry <- decode rawLastEntry
return XInfoStreamResponse{
xinfoMaxDeletedEntryId = Nothing
, xinfoEntriesAdded = Nothing
, xinfoRecordedFirstEntryId = Nothing
, ..}
decodeRedis6 Reply
a = Reply -> Either Reply XInfoStreamResponse
forall a b. a -> Either a b
Left Reply
a
decodeRedis7 :: Reply -> Either Reply XInfoStreamResponse
decodeRedis7 (MultiBulk (Just [
Bulk (Just ByteString
"length"), Integer Integer
xinfoStreamLength,
Bulk (Just ByteString
"radix-tree-keys"), Integer Integer
xinfoStreamRadixTreeKeys,
Bulk (Just ByteString
"radix-tree-nodes"), Integer Integer
xinfoStreamRadixTreeNodes,
Bulk (Just ByteString
"last-generated-id"), Bulk (Just ByteString
xinfoStreamLastEntryId),
Bulk (Just ByteString
"max-deleted-entry-id"), Bulk (Just ByteString
xinfoMaxDeletedEntryId),
Bulk (Just ByteString
"entries-added"), Integer Integer
xinfoEntriesAdded,
Bulk (Just ByteString
"recorded-first-entry-id"), Bulk (Just ByteString
xinfoRecordedFirstEntryId),
Bulk (Just ByteString
"groups"), Integer Integer
xinfoStreamNumGroups,
Bulk (Just ByteString
"first-entry"), Bulk Maybe ByteString
Nothing ,
Bulk (Just ByteString
"last-entry"), Bulk Maybe ByteString
Nothing ])) = do
XInfoStreamResponse -> Either Reply XInfoStreamResponse
forall a. a -> Either Reply a
forall (m :: * -> *) a. Monad m => a -> m a
return XInfoStreamEmptyResponse{
xinfoMaxDeletedEntryId :: Maybe ByteString
xinfoMaxDeletedEntryId = ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
xinfoMaxDeletedEntryId
, xinfoEntriesAdded :: Maybe Integer
xinfoEntriesAdded = Integer -> Maybe Integer
forall a. a -> Maybe a
Just Integer
xinfoEntriesAdded
, xinfoRecordedFirstEntryId :: Maybe ByteString
xinfoRecordedFirstEntryId = ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
xinfoRecordedFirstEntryId
, Integer
ByteString
xinfoStreamLength :: Integer
xinfoStreamRadixTreeKeys :: Integer
xinfoStreamRadixTreeNodes :: Integer
xinfoStreamNumGroups :: Integer
xinfoStreamLastEntryId :: ByteString
xinfoStreamLength :: Integer
xinfoStreamRadixTreeKeys :: Integer
xinfoStreamRadixTreeNodes :: Integer
xinfoStreamLastEntryId :: ByteString
xinfoStreamNumGroups :: Integer
..}
decodeRedis7 (MultiBulk (Just [
Bulk (Just ByteString
"length"), Integer Integer
xinfoStreamLength,
Bulk (Just ByteString
"radix-tree-keys"), Integer Integer
xinfoStreamRadixTreeKeys,
Bulk (Just ByteString
"radix-tree-nodes"), Integer Integer
xinfoStreamRadixTreeNodes,
Bulk (Just ByteString
"last-generated-id"), Bulk (Just ByteString
xinfoStreamLastEntryId),
Bulk (Just ByteString
"max-deleted-entry-id"), Bulk (Just ByteString
xinfoMaxDeletedEntryId),
Bulk (Just ByteString
"entries-added"), Integer Integer
xinfoEntriesAdded,
Bulk (Just ByteString
"recorded-first-entry-id"), Bulk (Just ByteString
xinfoRecordedFirstEntryId),
Bulk (Just ByteString
"groups"), Integer Integer
xinfoStreamNumGroups,
Bulk (Just ByteString
"first-entry"), Reply
rawFirstEntry ,
Bulk (Just ByteString
"last-entry"), Reply
rawLastEntry ])) = do
xinfoStreamFirstEntry <- Reply -> Either Reply StreamsRecord
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
rawFirstEntry
xinfoStreamLastEntry <- decode rawLastEntry
return XInfoStreamResponse{
xinfoMaxDeletedEntryId = Just xinfoMaxDeletedEntryId
, xinfoEntriesAdded = Just xinfoEntriesAdded
, xinfoRecordedFirstEntryId = Just xinfoRecordedFirstEntryId
, ..}
decodeRedis7 Reply
a = Reply -> Either Reply XInfoStreamResponse
forall a b. a -> Either a b
Left Reply
a
xinfoStream
:: (RedisCtx m f)
=> ByteString
-> m (f XInfoStreamResponse)
xinfoStream :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f XInfoStreamResponse)
xinfoStream ByteString
stream = [ByteString] -> m (f XInfoStreamResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"XINFO", ByteString
"STREAM", ByteString
stream]
xdel
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f Integer)
xdel :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
xdel ByteString
stream (ByteString
messageId:|[ByteString]
messageIds) = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"XDEL"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
streamByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
messageIdByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
messageIds)
xdelex
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f [XEntryDeletionResult])
xdelex :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f [XEntryDeletionResult])
xdelex ByteString
stream NonEmpty ByteString
messageIds =
ByteString
-> NonEmpty ByteString
-> XEntryDeletionOpts
-> m (f [XEntryDeletionResult])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty ByteString
-> XEntryDeletionOpts
-> m (f [XEntryDeletionResult])
xdelexOpts ByteString
stream NonEmpty ByteString
messageIds XEntryDeletionOpts
defaultXEntryDeletionOpts
xdelexOpts
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> XEntryDeletionOpts
-> m (f [XEntryDeletionResult])
xdelexOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> NonEmpty ByteString
-> XEntryDeletionOpts
-> m (f [XEntryDeletionResult])
xdelexOpts ByteString
stream NonEmpty ByteString
messageIds XEntryDeletionOpts
opts =
[ByteString] -> m (f [XEntryDeletionResult])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [XEntryDeletionResult]))
-> [ByteString] -> m (f [XEntryDeletionResult])
forall a b. (a -> b) -> a -> b
$ [ByteString
"XDELEX", ByteString
stream]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ XEntryDeletionOpts -> [ByteString]
xEntryDeletionOptsToArgs XEntryDeletionOpts
opts
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
xEntryIdsBlockArgs NonEmpty ByteString
messageIds
xcfgset
:: (RedisCtx m f)
=> ByteString
-> XCfgSetOpts
-> m (f Status)
xcfgset :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> XCfgSetOpts -> m (f Status)
xcfgset ByteString
key XCfgSetOpts{Maybe Integer
xCfgSetIdmpDuration :: XCfgSetOpts -> Maybe Integer
xCfgSetIdmpMaxsize :: XCfgSetOpts -> Maybe Integer
xCfgSetIdmpDuration :: Maybe Integer
xCfgSetIdmpMaxsize :: Maybe Integer
..} =
[ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$
[ByteString
"XCFGSET", ByteString
key]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
duration -> [ByteString
"IDMP-DURATION", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
duration]) Maybe Integer
xCfgSetIdmpDuration
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
maxsize -> [ByteString
"IDMP-MAXSIZE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
maxsize]) Maybe Integer
xCfgSetIdmpMaxsize
xidmprecord
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> ByteString
-> m (f Status)
xidmprecord :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> ByteString -> ByteString -> m (f Status)
xidmprecord ByteString
key ByteString
producerId ByteString
idempotencyId ByteString
streamId =
[ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"XIDMPRECORD", ByteString
key, ByteString
producerId, ByteString
idempotencyId, ByteString
streamId]
xnack
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> XNackMode
-> NonEmpty ByteString
-> m (f Integer)
xnack :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString -> XNackMode -> NonEmpty ByteString -> m (f Integer)
xnack ByteString
key ByteString
groupName XNackMode
mode NonEmpty ByteString
messageIds =
ByteString
-> ByteString
-> XNackMode
-> NonEmpty ByteString
-> XNackOpts
-> m (f Integer)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> XNackMode
-> NonEmpty ByteString
-> XNackOpts
-> m (f Integer)
xnackOpts ByteString
key ByteString
groupName XNackMode
mode NonEmpty ByteString
messageIds XNackOpts
defaultXNackOpts
xnackOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> XNackMode
-> NonEmpty ByteString
-> XNackOpts
-> m (f Integer)
xnackOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> XNackMode
-> NonEmpty ByteString
-> XNackOpts
-> m (f Integer)
xnackOpts ByteString
key ByteString
groupName XNackMode
mode NonEmpty ByteString
messageIds XNackOpts{Bool
Maybe Integer
xNackRetryCount :: XNackOpts -> Maybe Integer
xNackForce :: XNackOpts -> Bool
xNackRetryCount :: Maybe Integer
xNackForce :: Bool
..} =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$
[ByteString
"XNACK", ByteString
key, ByteString
groupName, XNackMode -> ByteString
forall a. RedisArg a => a -> ByteString
encode XNackMode
mode]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
xEntryIdsBlockArgs NonEmpty ByteString
messageIds
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
retryCount -> [ByteString
"RETRYCOUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
retryCount]) Maybe Integer
xNackRetryCount
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"FORCE" | Bool
xNackForce]
xtrim
:: (RedisCtx m f)
=> ByteString
-> TrimOpts
-> m (f Integer)
xtrim :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> TrimOpts -> m (f Integer)
xtrim ByteString
stream TrimOpts
opts = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"XTRIM"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:ByteString
streamByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:TrimOpts -> [ByteString]
internalTrimArgToList TrimOpts
opts)
inf :: RealFloat a => a
inf :: forall a. RealFloat a => a
inf = a
1 a -> a -> a
forall a. Fractional a => a -> a -> a
/ a
0
data AuthOpts = AuthOpts
{ AuthOpts -> Maybe ByteString
authOptsUsername
:: Maybe ByteString
}
deriving Int -> AuthOpts -> ShowS
[AuthOpts] -> ShowS
AuthOpts -> String
(Int -> AuthOpts -> ShowS)
-> (AuthOpts -> String) -> ([AuthOpts] -> ShowS) -> Show AuthOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AuthOpts -> ShowS
showsPrec :: Int -> AuthOpts -> ShowS
$cshow :: AuthOpts -> String
show :: AuthOpts -> String
$cshowList :: [AuthOpts] -> ShowS
showList :: [AuthOpts] -> ShowS
Show
defaultAuthOpts :: AuthOpts
defaultAuthOpts :: AuthOpts
defaultAuthOpts = AuthOpts
{ authOptsUsername :: Maybe ByteString
authOptsUsername = Maybe ByteString
forall a. Maybe a
Nothing
}
auth
:: RedisCtx m f
=> ByteString
-> m (f Status)
auth :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Status)
auth ByteString
password = ByteString -> AuthOpts -> m (f Status)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> AuthOpts -> m (f Status)
authOpts ByteString
password AuthOpts
defaultAuthOpts
authOpts
:: RedisCtx m f
=> ByteString
-> AuthOpts
-> m (f Status)
authOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> AuthOpts -> m (f Status)
authOpts ByteString
password AuthOpts{Maybe ByteString
authOptsUsername :: AuthOpts -> Maybe ByteString
authOptsUsername :: Maybe ByteString
..} = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$
[ByteString
"AUTH"] [ByteString] -> [ByteString] -> [ByteString]
forall a. Semigroup a => a -> a -> a
<> [ByteString]
-> (ByteString -> [ByteString]) -> Maybe ByteString -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:[]) Maybe ByteString
authOptsUsername [ByteString] -> [ByteString] -> [ByteString]
forall a. Semigroup a => a -> a -> a
<> [ByteString
password]
select
:: RedisCtx m f
=> Integer
-> m (f Status)
select :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> m (f Status)
select Integer
ix = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SELECT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
ix]
ping
:: (RedisCtx m f)
=> m (f Status)
ping :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
ping = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString
"PING"] )
data ClusterInfoResponse = ClusterInfoResponse
{ ClusterInfoResponse -> ClusterInfoResponseState
clusterInfoResponseState :: ClusterInfoResponseState,
ClusterInfoResponse -> Integer
clusterInfoResponseSlotsAssigned :: Integer,
ClusterInfoResponse -> Integer
clusterInfoResponseSlotsOK :: Integer,
ClusterInfoResponse -> Integer
clusterInfoResponseSlotsPfail :: Integer,
ClusterInfoResponse -> Integer
clusterInfoResponseSlotsFail :: Integer,
ClusterInfoResponse -> Integer
clusterInfoResponseKnownNodes :: Integer,
ClusterInfoResponse -> Integer
clusterInfoResponseSize :: Integer,
ClusterInfoResponse -> Integer
clusterInfoResponseCurrentEpoch :: Integer,
ClusterInfoResponse -> Integer
clusterInfoResponseMyEpoch :: Integer,
ClusterInfoResponse -> Integer
clusterInfoResponseStatsMessagesSent :: Integer,
ClusterInfoResponse -> Integer
clusterInfoResponseStatsMessagesReceived :: Integer,
ClusterInfoResponse -> Integer
clusterInfoResponseTotalLinksBufferLimitExceeded :: Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesPingSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesPingReceived :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesPongSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesPongReceived :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesMeetSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesMeetReceived :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesFailSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesFailReceived :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesPublishSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesPublishReceived :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesAuthReqSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesAuthReqReceived :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesAuthAckSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesAuthAckReceived :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesUpdateSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesUpdateReceived :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesMfstartSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesMfstartReceived :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesModuleSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesModuleReceived :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesPublishshardSent :: Maybe Integer,
ClusterInfoResponse -> Maybe Integer
clusterInfoResponseStatsMessagesPublishshardReceived :: Maybe Integer
}
deriving (Int -> ClusterInfoResponse -> ShowS
[ClusterInfoResponse] -> ShowS
ClusterInfoResponse -> String
(Int -> ClusterInfoResponse -> ShowS)
-> (ClusterInfoResponse -> String)
-> ([ClusterInfoResponse] -> ShowS)
-> Show ClusterInfoResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterInfoResponse -> ShowS
showsPrec :: Int -> ClusterInfoResponse -> ShowS
$cshow :: ClusterInfoResponse -> String
show :: ClusterInfoResponse -> String
$cshowList :: [ClusterInfoResponse] -> ShowS
showList :: [ClusterInfoResponse] -> ShowS
Show, ClusterInfoResponse -> ClusterInfoResponse -> Bool
(ClusterInfoResponse -> ClusterInfoResponse -> Bool)
-> (ClusterInfoResponse -> ClusterInfoResponse -> Bool)
-> Eq ClusterInfoResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterInfoResponse -> ClusterInfoResponse -> Bool
== :: ClusterInfoResponse -> ClusterInfoResponse -> Bool
$c/= :: ClusterInfoResponse -> ClusterInfoResponse -> Bool
/= :: ClusterInfoResponse -> ClusterInfoResponse -> Bool
Eq)
data ClusterInfoResponseState
= OK
| Down
deriving (Int -> ClusterInfoResponseState -> ShowS
[ClusterInfoResponseState] -> ShowS
ClusterInfoResponseState -> String
(Int -> ClusterInfoResponseState -> ShowS)
-> (ClusterInfoResponseState -> String)
-> ([ClusterInfoResponseState] -> ShowS)
-> Show ClusterInfoResponseState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterInfoResponseState -> ShowS
showsPrec :: Int -> ClusterInfoResponseState -> ShowS
$cshow :: ClusterInfoResponseState -> String
show :: ClusterInfoResponseState -> String
$cshowList :: [ClusterInfoResponseState] -> ShowS
showList :: [ClusterInfoResponseState] -> ShowS
Show, ClusterInfoResponseState -> ClusterInfoResponseState -> Bool
(ClusterInfoResponseState -> ClusterInfoResponseState -> Bool)
-> (ClusterInfoResponseState -> ClusterInfoResponseState -> Bool)
-> Eq ClusterInfoResponseState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterInfoResponseState -> ClusterInfoResponseState -> Bool
== :: ClusterInfoResponseState -> ClusterInfoResponseState -> Bool
$c/= :: ClusterInfoResponseState -> ClusterInfoResponseState -> Bool
/= :: ClusterInfoResponseState -> ClusterInfoResponseState -> Bool
Eq)
defClusterInfoResponse :: ClusterInfoResponse
defClusterInfoResponse :: ClusterInfoResponse
defClusterInfoResponse =
ClusterInfoResponse
{ clusterInfoResponseState :: ClusterInfoResponseState
clusterInfoResponseState = ClusterInfoResponseState
Down,
clusterInfoResponseSlotsAssigned :: Integer
clusterInfoResponseSlotsAssigned = Integer
0,
clusterInfoResponseSlotsOK :: Integer
clusterInfoResponseSlotsOK = Integer
0,
clusterInfoResponseSlotsPfail :: Integer
clusterInfoResponseSlotsPfail = Integer
0,
clusterInfoResponseSlotsFail :: Integer
clusterInfoResponseSlotsFail = Integer
0,
clusterInfoResponseKnownNodes :: Integer
clusterInfoResponseKnownNodes = Integer
0,
clusterInfoResponseSize :: Integer
clusterInfoResponseSize = Integer
0,
clusterInfoResponseCurrentEpoch :: Integer
clusterInfoResponseCurrentEpoch = Integer
0,
clusterInfoResponseMyEpoch :: Integer
clusterInfoResponseMyEpoch = Integer
0,
clusterInfoResponseStatsMessagesSent :: Integer
clusterInfoResponseStatsMessagesSent = Integer
0,
clusterInfoResponseStatsMessagesReceived :: Integer
clusterInfoResponseStatsMessagesReceived = Integer
0,
clusterInfoResponseTotalLinksBufferLimitExceeded :: Integer
clusterInfoResponseTotalLinksBufferLimitExceeded = Integer
0,
clusterInfoResponseStatsMessagesPingSent :: Maybe Integer
clusterInfoResponseStatsMessagesPingSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesPingReceived :: Maybe Integer
clusterInfoResponseStatsMessagesPingReceived = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesPongSent :: Maybe Integer
clusterInfoResponseStatsMessagesPongSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesPongReceived :: Maybe Integer
clusterInfoResponseStatsMessagesPongReceived = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesMeetSent :: Maybe Integer
clusterInfoResponseStatsMessagesMeetSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesMeetReceived :: Maybe Integer
clusterInfoResponseStatsMessagesMeetReceived = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesFailSent :: Maybe Integer
clusterInfoResponseStatsMessagesFailSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesFailReceived :: Maybe Integer
clusterInfoResponseStatsMessagesFailReceived = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesPublishSent :: Maybe Integer
clusterInfoResponseStatsMessagesPublishSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesPublishReceived :: Maybe Integer
clusterInfoResponseStatsMessagesPublishReceived = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesAuthReqSent :: Maybe Integer
clusterInfoResponseStatsMessagesAuthReqSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesAuthReqReceived :: Maybe Integer
clusterInfoResponseStatsMessagesAuthReqReceived = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesAuthAckSent :: Maybe Integer
clusterInfoResponseStatsMessagesAuthAckSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesAuthAckReceived :: Maybe Integer
clusterInfoResponseStatsMessagesAuthAckReceived = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesUpdateSent :: Maybe Integer
clusterInfoResponseStatsMessagesUpdateSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesUpdateReceived :: Maybe Integer
clusterInfoResponseStatsMessagesUpdateReceived = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesMfstartSent :: Maybe Integer
clusterInfoResponseStatsMessagesMfstartSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesMfstartReceived :: Maybe Integer
clusterInfoResponseStatsMessagesMfstartReceived = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesModuleSent :: Maybe Integer
clusterInfoResponseStatsMessagesModuleSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesModuleReceived :: Maybe Integer
clusterInfoResponseStatsMessagesModuleReceived = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesPublishshardSent :: Maybe Integer
clusterInfoResponseStatsMessagesPublishshardSent = Maybe Integer
forall a. Maybe a
Nothing,
clusterInfoResponseStatsMessagesPublishshardReceived :: Maybe Integer
clusterInfoResponseStatsMessagesPublishshardReceived = Maybe Integer
forall a. Maybe a
Nothing
}
parseClusterInfoResponse :: [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse :: [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fields ClusterInfoResponse
resp = case [[ByteString]]
fields of
[] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ClusterInfoResponse
resp
([ByteString
"cluster_state", ByteString
state] : [[ByteString]]
fs) -> ByteString -> Maybe ClusterInfoResponseState
forall {a}.
(Eq a, IsString a) =>
a -> Maybe ClusterInfoResponseState
parseState ByteString
state Maybe ClusterInfoResponseState
-> (ClusterInfoResponseState -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \ClusterInfoResponseState
s -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseState = s}
([ByteString
"cluster_slots_assigned", ByteString
value] : [[ByteString]]
fs) -> ByteString -> Maybe Integer
parseInteger ByteString
value Maybe Integer
-> (Integer -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Integer
v -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseSlotsAssigned = v}
([ByteString
"cluster_slots_ok", ByteString
value] : [[ByteString]]
fs) -> ByteString -> Maybe Integer
parseInteger ByteString
value Maybe Integer
-> (Integer -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Integer
v -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseSlotsOK = v}
([ByteString
"cluster_slots_pfail", ByteString
value] : [[ByteString]]
fs) -> ByteString -> Maybe Integer
parseInteger ByteString
value Maybe Integer
-> (Integer -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Integer
v -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseSlotsPfail = v}
([ByteString
"cluster_slots_fail", ByteString
value] : [[ByteString]]
fs) -> ByteString -> Maybe Integer
parseInteger ByteString
value Maybe Integer
-> (Integer -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Integer
v -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseSlotsFail = v}
([ByteString
"cluster_known_nodes", ByteString
value] : [[ByteString]]
fs) -> ByteString -> Maybe Integer
parseInteger ByteString
value Maybe Integer
-> (Integer -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Integer
v -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseKnownNodes = v}
([ByteString
"cluster_size", ByteString
value] : [[ByteString]]
fs) -> ByteString -> Maybe Integer
parseInteger ByteString
value Maybe Integer
-> (Integer -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Integer
v -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseSize = v}
([ByteString
"cluster_current_epoch", ByteString
value] : [[ByteString]]
fs) -> ByteString -> Maybe Integer
parseInteger ByteString
value Maybe Integer
-> (Integer -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Integer
v -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseCurrentEpoch = v}
([ByteString
"cluster_my_epoch", ByteString
value] : [[ByteString]]
fs) -> ByteString -> Maybe Integer
parseInteger ByteString
value Maybe Integer
-> (Integer -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Integer
v -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseMyEpoch = v}
([ByteString
"cluster_stats_messages_sent", ByteString
value] : [[ByteString]]
fs) -> ByteString -> Maybe Integer
parseInteger ByteString
value Maybe Integer
-> (Integer -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Integer
v -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesSent = v}
([ByteString
"cluster_stats_messages_received", ByteString
value] : [[ByteString]]
fs) -> ByteString -> Maybe Integer
parseInteger ByteString
value Maybe Integer
-> (Integer -> Maybe ClusterInfoResponse)
-> Maybe ClusterInfoResponse
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \Integer
v -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesReceived = v}
([ByteString
"total_cluster_links_buffer_limit_exceeded", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseTotalLinksBufferLimitExceeded = fromMaybe 0 $ parseInteger value}
([ByteString
"cluster_stats_messages_ping_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesPingSent = parseInteger value}
([ByteString
"cluster_stats_messages_ping_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesPingReceived = parseInteger value}
([ByteString
"cluster_stats_messages_pong_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesPongSent = parseInteger value}
([ByteString
"cluster_stats_messages_pong_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesPongReceived = parseInteger value}
([ByteString
"cluster_stats_messages_meet_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesMeetSent = parseInteger value}
([ByteString
"cluster_stats_messages_meet_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesMeetReceived = parseInteger value}
([ByteString
"cluster_stats_messages_fail_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesFailSent = parseInteger value}
([ByteString
"cluster_stats_messages_fail_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesFailReceived = parseInteger value}
([ByteString
"cluster_stats_messages_publish_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesPublishSent = parseInteger value}
([ByteString
"cluster_stats_messages_publish_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesPublishReceived = parseInteger value}
([ByteString
"cluster_stats_messages_auth_req_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesAuthReqSent = parseInteger value}
([ByteString
"cluster_stats_messages_auth_req_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesAuthReqReceived = parseInteger value}
([ByteString
"cluster_stats_messages_auth_ack_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesAuthAckSent = parseInteger value}
([ByteString
"cluster_stats_messages_auth_ack_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesAuthAckReceived = parseInteger value}
([ByteString
"cluster_stats_messages_update_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesUpdateSent = parseInteger value}
([ByteString
"cluster_stats_messages_update_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesUpdateReceived = parseInteger value}
([ByteString
"cluster_stats_messages_mfstart_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesMfstartSent = parseInteger value}
([ByteString
"cluster_stats_messages_mfstart_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesMfstartReceived = parseInteger value}
([ByteString
"cluster_stats_messages_module_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesModuleSent = parseInteger value}
([ByteString
"cluster_stats_messages_module_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesModuleReceived = parseInteger value}
([ByteString
"cluster_stats_messages_publishshard_sent", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesPublishshardSent = parseInteger value}
([ByteString
"cluster_stats_messages_publishshard_received", ByteString
value] : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs (ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse -> Maybe ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ClusterInfoResponse
resp {clusterInfoResponseStatsMessagesPublishshardReceived = parseInteger value}
([ByteString]
_ : [[ByteString]]
fs) -> [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse [[ByteString]]
fs ClusterInfoResponse
resp
where
parseState :: a -> Maybe ClusterInfoResponseState
parseState a
bs = case a
bs of
a
"ok" -> ClusterInfoResponseState -> Maybe ClusterInfoResponseState
forall a. a -> Maybe a
Just ClusterInfoResponseState
OK
a
"fail" -> ClusterInfoResponseState -> Maybe ClusterInfoResponseState
forall a. a -> Maybe a
Just ClusterInfoResponseState
Down
a
_ -> Maybe ClusterInfoResponseState
forall a. Maybe a
Nothing
parseInteger :: ByteString -> Maybe Integer
parseInteger = ((Integer, ByteString) -> Integer)
-> Maybe (Integer, ByteString) -> Maybe Integer
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Integer, ByteString) -> Integer
forall a b. (a, b) -> a
fst (Maybe (Integer, ByteString) -> Maybe Integer)
-> (ByteString -> Maybe (Integer, ByteString))
-> ByteString
-> Maybe Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Maybe (Integer, ByteString)
Char8.readInteger
instance RedisResult ClusterInfoResponse where
decode :: Reply -> Either Reply ClusterInfoResponse
decode r :: Reply
r@(Bulk (Just ByteString
bulkData)) =
Either Reply ClusterInfoResponse
-> (ClusterInfoResponse -> Either Reply ClusterInfoResponse)
-> Maybe ClusterInfoResponse
-> Either Reply ClusterInfoResponse
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Reply -> Either Reply ClusterInfoResponse
forall a b. a -> Either a b
Left Reply
r) ClusterInfoResponse -> Either Reply ClusterInfoResponse
forall a b. b -> Either a b
Right
(Maybe ClusterInfoResponse -> Either Reply ClusterInfoResponse)
-> ([ByteString] -> Maybe ClusterInfoResponse)
-> [ByteString]
-> Either Reply ClusterInfoResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([[ByteString]]
-> ClusterInfoResponse -> Maybe ClusterInfoResponse)
-> ClusterInfoResponse
-> [[ByteString]]
-> Maybe ClusterInfoResponse
forall a b c. (a -> b -> c) -> b -> a -> c
flip [[ByteString]] -> ClusterInfoResponse -> Maybe ClusterInfoResponse
parseClusterInfoResponse ClusterInfoResponse
defClusterInfoResponse
([[ByteString]] -> Maybe ClusterInfoResponse)
-> ([ByteString] -> [[ByteString]])
-> [ByteString]
-> Maybe ClusterInfoResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ByteString -> [ByteString]) -> [ByteString] -> [[ByteString]]
forall a b. (a -> b) -> [a] -> [b]
map (Char -> ByteString -> [ByteString]
Char8.split Char
':' (ByteString -> [ByteString])
-> (ByteString -> ByteString) -> ByteString -> [ByteString]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> ByteString -> ByteString
Char8.takeWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
'\r'))
([ByteString] -> Either Reply ClusterInfoResponse)
-> [ByteString] -> Either Reply ClusterInfoResponse
forall a b. (a -> b) -> a -> b
$ ByteString -> [ByteString]
Char8.lines ByteString
bulkData
decode Reply
r = Reply -> Either Reply ClusterInfoResponse
forall a b. a -> Either a b
Left Reply
r
clusterInfo :: RedisCtx m f => m (f ClusterInfoResponse)
clusterInfo :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f ClusterInfoResponse)
clusterInfo = [ByteString] -> m (f ClusterInfoResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLUSTER", ByteString
"INFO"]
clusterMyshardid
:: (RedisCtx m f)
=> m (f ByteString)
clusterMyshardid :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f ByteString)
clusterMyshardid = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLUSTER", ByteString
"MYSHARDID"]
data ClusterNodesResponse = ClusterNodesResponse
{ ClusterNodesResponse -> [ClusterNodesResponseEntry]
clusterNodesResponseEntries :: [ClusterNodesResponseEntry]
} deriving (Int -> ClusterNodesResponse -> ShowS
[ClusterNodesResponse] -> ShowS
ClusterNodesResponse -> String
(Int -> ClusterNodesResponse -> ShowS)
-> (ClusterNodesResponse -> String)
-> ([ClusterNodesResponse] -> ShowS)
-> Show ClusterNodesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterNodesResponse -> ShowS
showsPrec :: Int -> ClusterNodesResponse -> ShowS
$cshow :: ClusterNodesResponse -> String
show :: ClusterNodesResponse -> String
$cshowList :: [ClusterNodesResponse] -> ShowS
showList :: [ClusterNodesResponse] -> ShowS
Show, ClusterNodesResponse -> ClusterNodesResponse -> Bool
(ClusterNodesResponse -> ClusterNodesResponse -> Bool)
-> (ClusterNodesResponse -> ClusterNodesResponse -> Bool)
-> Eq ClusterNodesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterNodesResponse -> ClusterNodesResponse -> Bool
== :: ClusterNodesResponse -> ClusterNodesResponse -> Bool
$c/= :: ClusterNodesResponse -> ClusterNodesResponse -> Bool
/= :: ClusterNodesResponse -> ClusterNodesResponse -> Bool
Eq)
data ClusterNodesResponseEntry = ClusterNodesResponseEntry { ClusterNodesResponseEntry -> ByteString
clusterNodesResponseNodeId :: ByteString
, ClusterNodesResponseEntry -> ByteString
clusterNodesResponseNodeIp :: ByteString
, ClusterNodesResponseEntry -> Integer
clusterNodesResponseNodePort :: Integer
, ClusterNodesResponseEntry -> [ByteString]
clusterNodesResponseNodeFlags :: [ByteString]
, ClusterNodesResponseEntry -> Maybe ByteString
clusterNodesResponseMasterId :: Maybe ByteString
, ClusterNodesResponseEntry -> Integer
clusterNodesResponsePingSent :: Integer
, ClusterNodesResponseEntry -> Integer
clusterNodesResponsePongReceived :: Integer
, ClusterNodesResponseEntry -> Integer
clusterNodesResponseConfigEpoch :: Integer
, ClusterNodesResponseEntry -> ByteString
clusterNodesResponseLinkState :: ByteString
, ClusterNodesResponseEntry -> [ClusterNodesResponseSlotSpec]
clusterNodesResponseSlots :: [ClusterNodesResponseSlotSpec]
} deriving (Int -> ClusterNodesResponseEntry -> ShowS
[ClusterNodesResponseEntry] -> ShowS
ClusterNodesResponseEntry -> String
(Int -> ClusterNodesResponseEntry -> ShowS)
-> (ClusterNodesResponseEntry -> String)
-> ([ClusterNodesResponseEntry] -> ShowS)
-> Show ClusterNodesResponseEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterNodesResponseEntry -> ShowS
showsPrec :: Int -> ClusterNodesResponseEntry -> ShowS
$cshow :: ClusterNodesResponseEntry -> String
show :: ClusterNodesResponseEntry -> String
$cshowList :: [ClusterNodesResponseEntry] -> ShowS
showList :: [ClusterNodesResponseEntry] -> ShowS
Show, ClusterNodesResponseEntry -> ClusterNodesResponseEntry -> Bool
(ClusterNodesResponseEntry -> ClusterNodesResponseEntry -> Bool)
-> (ClusterNodesResponseEntry -> ClusterNodesResponseEntry -> Bool)
-> Eq ClusterNodesResponseEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterNodesResponseEntry -> ClusterNodesResponseEntry -> Bool
== :: ClusterNodesResponseEntry -> ClusterNodesResponseEntry -> Bool
$c/= :: ClusterNodesResponseEntry -> ClusterNodesResponseEntry -> Bool
/= :: ClusterNodesResponseEntry -> ClusterNodesResponseEntry -> Bool
Eq)
data ClusterNodesResponseSlotSpec
= ClusterNodesResponseSingleSlot Integer
| ClusterNodesResponseSlotRange Integer Integer
| ClusterNodesResponseSlotImporting Integer ByteString
| ClusterNodesResponseSlotMigrating Integer ByteString deriving (Int -> ClusterNodesResponseSlotSpec -> ShowS
[ClusterNodesResponseSlotSpec] -> ShowS
ClusterNodesResponseSlotSpec -> String
(Int -> ClusterNodesResponseSlotSpec -> ShowS)
-> (ClusterNodesResponseSlotSpec -> String)
-> ([ClusterNodesResponseSlotSpec] -> ShowS)
-> Show ClusterNodesResponseSlotSpec
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterNodesResponseSlotSpec -> ShowS
showsPrec :: Int -> ClusterNodesResponseSlotSpec -> ShowS
$cshow :: ClusterNodesResponseSlotSpec -> String
show :: ClusterNodesResponseSlotSpec -> String
$cshowList :: [ClusterNodesResponseSlotSpec] -> ShowS
showList :: [ClusterNodesResponseSlotSpec] -> ShowS
Show, ClusterNodesResponseSlotSpec
-> ClusterNodesResponseSlotSpec -> Bool
(ClusterNodesResponseSlotSpec
-> ClusterNodesResponseSlotSpec -> Bool)
-> (ClusterNodesResponseSlotSpec
-> ClusterNodesResponseSlotSpec -> Bool)
-> Eq ClusterNodesResponseSlotSpec
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterNodesResponseSlotSpec
-> ClusterNodesResponseSlotSpec -> Bool
== :: ClusterNodesResponseSlotSpec
-> ClusterNodesResponseSlotSpec -> Bool
$c/= :: ClusterNodesResponseSlotSpec
-> ClusterNodesResponseSlotSpec -> Bool
/= :: ClusterNodesResponseSlotSpec
-> ClusterNodesResponseSlotSpec -> Bool
Eq)
instance RedisResult ClusterNodesResponse where
decode :: Reply -> Either Reply ClusterNodesResponse
decode r :: Reply
r@(Bulk (Just ByteString
bulkData)) = Either Reply ClusterNodesResponse
-> (ClusterNodesResponse -> Either Reply ClusterNodesResponse)
-> Maybe ClusterNodesResponse
-> Either Reply ClusterNodesResponse
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Reply -> Either Reply ClusterNodesResponse
forall a b. a -> Either a b
Left Reply
r) ClusterNodesResponse -> Either Reply ClusterNodesResponse
forall a b. b -> Either a b
Right (Maybe ClusterNodesResponse -> Either Reply ClusterNodesResponse)
-> Maybe ClusterNodesResponse -> Either Reply ClusterNodesResponse
forall a b. (a -> b) -> a -> b
$ do
infos <- (ByteString -> Maybe ClusterNodesResponseEntry)
-> [ByteString] -> Maybe [ClusterNodesResponseEntry]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ByteString -> Maybe ClusterNodesResponseEntry
parseNodeInfo ([ByteString] -> Maybe [ClusterNodesResponseEntry])
-> [ByteString] -> Maybe [ClusterNodesResponseEntry]
forall a b. (a -> b) -> a -> b
$ ByteString -> [ByteString]
Char8.lines ByteString
bulkData
return $ ClusterNodesResponse infos where
parseNodeInfo :: ByteString -> Maybe ClusterNodesResponseEntry
parseNodeInfo :: ByteString -> Maybe ClusterNodesResponseEntry
parseNodeInfo ByteString
line = case ByteString -> [ByteString]
Char8.words ByteString
line of
(ByteString
nodeId : ByteString
hostNamePort : ByteString
flags : ByteString
masterNodeId : ByteString
pingSent : ByteString
pongRecv : ByteString
epoch : ByteString
linkState : [ByteString]
slots) ->
case Char -> ByteString -> [ByteString]
Char8.split Char
':' ByteString
hostNamePort of
[ByteString
hostName, ByteString
port] -> ByteString
-> ByteString
-> Integer
-> [ByteString]
-> Maybe ByteString
-> Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry
ClusterNodesResponseEntry (ByteString
-> ByteString
-> Integer
-> [ByteString]
-> Maybe ByteString
-> Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
-> Maybe ByteString
-> Maybe
(ByteString
-> Integer
-> [ByteString]
-> Maybe ByteString
-> Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe ByteString
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ByteString
nodeId
Maybe
(ByteString
-> Integer
-> [ByteString]
-> Maybe ByteString
-> Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
-> Maybe ByteString
-> Maybe
(Integer
-> [ByteString]
-> Maybe ByteString
-> Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> Maybe ByteString
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ByteString
hostName
Maybe
(Integer
-> [ByteString]
-> Maybe ByteString
-> Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
-> Maybe Integer
-> Maybe
([ByteString]
-> Maybe ByteString
-> Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> Maybe Integer
readInteger ByteString
port
Maybe
([ByteString]
-> Maybe ByteString
-> Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
-> Maybe [ByteString]
-> Maybe
(Maybe ByteString
-> Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [ByteString] -> Maybe [ByteString]
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Char -> ByteString -> [ByteString]
Char8.split Char
',' ByteString
flags)
Maybe
(Maybe ByteString
-> Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
-> Maybe (Maybe ByteString)
-> Maybe
(Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe ByteString -> Maybe (Maybe ByteString)
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> Maybe ByteString
readMasterNodeId ByteString
masterNodeId)
Maybe
(Integer
-> Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
-> Maybe Integer
-> Maybe
(Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> Maybe Integer
readInteger ByteString
pingSent
Maybe
(Integer
-> Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
-> Maybe Integer
-> Maybe
(Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> Maybe Integer
readInteger ByteString
pongRecv
Maybe
(Integer
-> ByteString
-> [ClusterNodesResponseSlotSpec]
-> ClusterNodesResponseEntry)
-> Maybe Integer
-> Maybe
(ByteString
-> [ClusterNodesResponseSlotSpec] -> ClusterNodesResponseEntry)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> Maybe Integer
readInteger ByteString
epoch
Maybe
(ByteString
-> [ClusterNodesResponseSlotSpec] -> ClusterNodesResponseEntry)
-> Maybe ByteString
-> Maybe
([ClusterNodesResponseSlotSpec] -> ClusterNodesResponseEntry)
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ByteString -> Maybe ByteString
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ByteString
linkState
Maybe ([ClusterNodesResponseSlotSpec] -> ClusterNodesResponseEntry)
-> Maybe [ClusterNodesResponseSlotSpec]
-> Maybe ClusterNodesResponseEntry
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ([ClusterNodesResponseSlotSpec]
-> Maybe [ClusterNodesResponseSlotSpec]
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([ClusterNodesResponseSlotSpec]
-> Maybe [ClusterNodesResponseSlotSpec])
-> ([Maybe ClusterNodesResponseSlotSpec]
-> [ClusterNodesResponseSlotSpec])
-> [Maybe ClusterNodesResponseSlotSpec]
-> Maybe [ClusterNodesResponseSlotSpec]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe ClusterNodesResponseSlotSpec]
-> [ClusterNodesResponseSlotSpec]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe ClusterNodesResponseSlotSpec]
-> Maybe [ClusterNodesResponseSlotSpec])
-> [Maybe ClusterNodesResponseSlotSpec]
-> Maybe [ClusterNodesResponseSlotSpec]
forall a b. (a -> b) -> a -> b
$ (ByteString -> Maybe ClusterNodesResponseSlotSpec)
-> [ByteString] -> [Maybe ClusterNodesResponseSlotSpec]
forall a b. (a -> b) -> [a] -> [b]
map ByteString -> Maybe ClusterNodesResponseSlotSpec
readNodeSlot [ByteString]
slots)
[ByteString]
_ -> Maybe ClusterNodesResponseEntry
forall a. Maybe a
Nothing
[ByteString]
_ -> Maybe ClusterNodesResponseEntry
forall a. Maybe a
Nothing
readInteger :: ByteString -> Maybe Integer
readInteger :: ByteString -> Maybe Integer
readInteger = ((Integer, ByteString) -> Integer)
-> Maybe (Integer, ByteString) -> Maybe Integer
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Integer, ByteString) -> Integer
forall a b. (a, b) -> a
fst (Maybe (Integer, ByteString) -> Maybe Integer)
-> (ByteString -> Maybe (Integer, ByteString))
-> ByteString
-> Maybe Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Maybe (Integer, ByteString)
Char8.readInteger
readMasterNodeId :: ByteString -> Maybe ByteString
readMasterNodeId :: ByteString -> Maybe ByteString
readMasterNodeId ByteString
"-" = Maybe ByteString
forall a. Maybe a
Nothing
readMasterNodeId ByteString
nodeId = ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just ByteString
nodeId
readNodeSlot :: ByteString -> Maybe ClusterNodesResponseSlotSpec
readNodeSlot :: ByteString -> Maybe ClusterNodesResponseSlotSpec
readNodeSlot ByteString
slotSpec = case Char
'[' Char -> ByteString -> Bool
`Char8.elem` ByteString
slotSpec of
Bool
True -> ByteString -> Maybe ClusterNodesResponseSlotSpec
readSlotImportMigrate ByteString
slotSpec
Bool
False -> case Char
'-' Char -> ByteString -> Bool
`Char8.elem` ByteString
slotSpec of
Bool
True -> ByteString -> Maybe ClusterNodesResponseSlotSpec
readSlotRange ByteString
slotSpec
Bool
False -> Integer -> ClusterNodesResponseSlotSpec
ClusterNodesResponseSingleSlot (Integer -> ClusterNodesResponseSlotSpec)
-> Maybe Integer -> Maybe ClusterNodesResponseSlotSpec
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe Integer
readInteger ByteString
slotSpec
readSlotImportMigrate :: ByteString -> Maybe ClusterNodesResponseSlotSpec
readSlotImportMigrate :: ByteString -> Maybe ClusterNodesResponseSlotSpec
readSlotImportMigrate ByteString
slotSpec = case ByteString -> ByteString -> (ByteString, ByteString)
BS.breakSubstring ByteString
"->-" ByteString
slotSpec of
(ByteString
_, ByteString
"") -> case ByteString -> ByteString -> (ByteString, ByteString)
BS.breakSubstring ByteString
"-<-" ByteString
slotSpec of
(ByteString
_, ByteString
"") -> Maybe ClusterNodesResponseSlotSpec
forall a. Maybe a
Nothing
(ByteString
leftPart, ByteString
rightPart) -> Integer -> ByteString -> ClusterNodesResponseSlotSpec
ClusterNodesResponseSlotImporting
(Integer -> ByteString -> ClusterNodesResponseSlotSpec)
-> Maybe Integer
-> Maybe (ByteString -> ClusterNodesResponseSlotSpec)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ByteString -> Maybe Integer
readInteger (ByteString -> Maybe Integer) -> ByteString -> Maybe Integer
forall a b. (a -> b) -> a -> b
$ Int -> ByteString -> ByteString
Char8.drop Int
1 ByteString
leftPart)
Maybe (ByteString -> ClusterNodesResponseSlotSpec)
-> Maybe ByteString -> Maybe ClusterNodesResponseSlotSpec
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ByteString -> Maybe ByteString
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> Maybe ByteString) -> ByteString -> Maybe ByteString
forall a b. (a -> b) -> a -> b
$ Int -> ByteString -> ByteString
BS.take (ByteString -> Int
BS.length ByteString
rightPart Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) ByteString
rightPart)
(ByteString
leftPart, ByteString
rightPart) -> Integer -> ByteString -> ClusterNodesResponseSlotSpec
ClusterNodesResponseSlotMigrating
(Integer -> ByteString -> ClusterNodesResponseSlotSpec)
-> Maybe Integer
-> Maybe (ByteString -> ClusterNodesResponseSlotSpec)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ByteString -> Maybe Integer
readInteger (ByteString -> Maybe Integer) -> ByteString -> Maybe Integer
forall a b. (a -> b) -> a -> b
$ Int -> ByteString -> ByteString
Char8.drop Int
1 ByteString
leftPart)
Maybe (ByteString -> ClusterNodesResponseSlotSpec)
-> Maybe ByteString -> Maybe ClusterNodesResponseSlotSpec
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ByteString -> Maybe ByteString
forall a. a -> Maybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ByteString -> Maybe ByteString) -> ByteString -> Maybe ByteString
forall a b. (a -> b) -> a -> b
$ Int -> ByteString -> ByteString
BS.take (ByteString -> Int
BS.length ByteString
rightPart Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1) ByteString
rightPart)
readSlotRange :: ByteString -> Maybe ClusterNodesResponseSlotSpec
readSlotRange :: ByteString -> Maybe ClusterNodesResponseSlotSpec
readSlotRange ByteString
slotSpec = case ByteString -> ByteString -> (ByteString, ByteString)
BS.breakSubstring ByteString
"-" ByteString
slotSpec of
(ByteString
_, ByteString
"") -> Maybe ClusterNodesResponseSlotSpec
forall a. Maybe a
Nothing
(ByteString
leftPart, ByteString
rightPart) -> Integer -> Integer -> ClusterNodesResponseSlotSpec
ClusterNodesResponseSlotRange
(Integer -> Integer -> ClusterNodesResponseSlotSpec)
-> Maybe Integer -> Maybe (Integer -> ClusterNodesResponseSlotSpec)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe Integer
readInteger ByteString
leftPart
Maybe (Integer -> ClusterNodesResponseSlotSpec)
-> Maybe Integer -> Maybe ClusterNodesResponseSlotSpec
forall a b. Maybe (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (ByteString -> Maybe Integer
readInteger (ByteString -> Maybe Integer) -> ByteString -> Maybe Integer
forall a b. (a -> b) -> a -> b
$ Int -> ByteString -> ByteString
BS.drop Int
1 ByteString
rightPart)
decode Reply
r = Reply -> Either Reply ClusterNodesResponse
forall a b. a -> Either a b
Left Reply
r
clusterNodes
:: (RedisCtx m f)
=> m (f ClusterNodesResponse)
clusterNodes :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f ClusterNodesResponse)
clusterNodes = [ByteString] -> m (f ClusterNodesResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f ClusterNodesResponse))
-> [ByteString] -> m (f ClusterNodesResponse)
forall a b. (a -> b) -> a -> b
$ [ByteString
"CLUSTER", ByteString
"NODES"]
data ClusterSlotsResponse = ClusterSlotsResponse { ClusterSlotsResponse -> [ClusterSlotsResponseEntry]
clusterSlotsResponseEntries :: [ClusterSlotsResponseEntry] } deriving (Int -> ClusterSlotsResponse -> ShowS
[ClusterSlotsResponse] -> ShowS
ClusterSlotsResponse -> String
(Int -> ClusterSlotsResponse -> ShowS)
-> (ClusterSlotsResponse -> String)
-> ([ClusterSlotsResponse] -> ShowS)
-> Show ClusterSlotsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterSlotsResponse -> ShowS
showsPrec :: Int -> ClusterSlotsResponse -> ShowS
$cshow :: ClusterSlotsResponse -> String
show :: ClusterSlotsResponse -> String
$cshowList :: [ClusterSlotsResponse] -> ShowS
showList :: [ClusterSlotsResponse] -> ShowS
Show)
data ClusterSlotsNode = ClusterSlotsNode
{ ClusterSlotsNode -> ByteString
clusterSlotsNodeIP :: ByteString
, ClusterSlotsNode -> Int
clusterSlotsNodePort :: Int
, ClusterSlotsNode -> ByteString
clusterSlotsNodeID :: ByteString
} deriving (Int -> ClusterSlotsNode -> ShowS
[ClusterSlotsNode] -> ShowS
ClusterSlotsNode -> String
(Int -> ClusterSlotsNode -> ShowS)
-> (ClusterSlotsNode -> String)
-> ([ClusterSlotsNode] -> ShowS)
-> Show ClusterSlotsNode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterSlotsNode -> ShowS
showsPrec :: Int -> ClusterSlotsNode -> ShowS
$cshow :: ClusterSlotsNode -> String
show :: ClusterSlotsNode -> String
$cshowList :: [ClusterSlotsNode] -> ShowS
showList :: [ClusterSlotsNode] -> ShowS
Show)
data ClusterSlotsResponseEntry = ClusterSlotsResponseEntry
{ ClusterSlotsResponseEntry -> Int
clusterSlotsResponseEntryStartSlot :: Int
, ClusterSlotsResponseEntry -> Int
clusterSlotsResponseEntryEndSlot :: Int
, ClusterSlotsResponseEntry -> ClusterSlotsNode
clusterSlotsResponseEntryMaster :: ClusterSlotsNode
, ClusterSlotsResponseEntry -> [ClusterSlotsNode]
clusterSlotsResponseEntryReplicas :: [ClusterSlotsNode]
} deriving (Int -> ClusterSlotsResponseEntry -> ShowS
[ClusterSlotsResponseEntry] -> ShowS
ClusterSlotsResponseEntry -> String
(Int -> ClusterSlotsResponseEntry -> ShowS)
-> (ClusterSlotsResponseEntry -> String)
-> ([ClusterSlotsResponseEntry] -> ShowS)
-> Show ClusterSlotsResponseEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterSlotsResponseEntry -> ShowS
showsPrec :: Int -> ClusterSlotsResponseEntry -> ShowS
$cshow :: ClusterSlotsResponseEntry -> String
show :: ClusterSlotsResponseEntry -> String
$cshowList :: [ClusterSlotsResponseEntry] -> ShowS
showList :: [ClusterSlotsResponseEntry] -> ShowS
Show)
instance RedisResult ClusterSlotsResponse where
decode :: Reply -> Either Reply ClusterSlotsResponse
decode (MultiBulk (Just [Reply]
bulkData)) = do
clusterSlotsResponseEntries <- (Reply -> Either Reply ClusterSlotsResponseEntry)
-> [Reply] -> Either Reply [ClusterSlotsResponseEntry]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply ClusterSlotsResponseEntry
forall a. RedisResult a => Reply -> Either Reply a
decode [Reply]
bulkData
return ClusterSlotsResponse{..}
decode Reply
a = Reply -> Either Reply ClusterSlotsResponse
forall a b. a -> Either a b
Left Reply
a
instance RedisResult ClusterSlotsResponseEntry where
decode :: Reply -> Either Reply ClusterSlotsResponseEntry
decode (MultiBulk (Just
((Integer Integer
startSlot):(Integer Integer
endSlot):Reply
masterData:[Reply]
replicas))) = do
clusterSlotsResponseEntryMaster <- Reply -> Either Reply ClusterSlotsNode
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
masterData
clusterSlotsResponseEntryReplicas <- mapM decode replicas
let clusterSlotsResponseEntryStartSlot = Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
startSlot
let clusterSlotsResponseEntryEndSlot = Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
endSlot
return ClusterSlotsResponseEntry{..}
decode Reply
a = Reply -> Either Reply ClusterSlotsResponseEntry
forall a b. a -> Either a b
Left Reply
a
instance RedisResult ClusterSlotsNode where
decode :: Reply -> Either Reply ClusterSlotsNode
decode (MultiBulk (Just ((Bulk (Just ByteString
clusterSlotsNodeIP)):(Integer Integer
port):(Bulk (Just ByteString
clusterSlotsNodeID)):[Reply]
_))) = ClusterSlotsNode -> Either Reply ClusterSlotsNode
forall a b. b -> Either a b
Right ClusterSlotsNode{Int
ByteString
clusterSlotsNodeIP :: ByteString
clusterSlotsNodePort :: Int
clusterSlotsNodeID :: ByteString
clusterSlotsNodeIP :: ByteString
clusterSlotsNodeID :: ByteString
clusterSlotsNodePort :: Int
..}
where clusterSlotsNodePort :: Int
clusterSlotsNodePort = Integer -> Int
forall a. Num a => Integer -> a
fromInteger Integer
port
decode Reply
a = Reply -> Either Reply ClusterSlotsNode
forall a b. a -> Either a b
Left Reply
a
clusterSlots
:: (RedisCtx m f)
=> m (f ClusterSlotsResponse)
clusterSlots :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f ClusterSlotsResponse)
clusterSlots = [ByteString] -> m (f ClusterSlotsResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f ClusterSlotsResponse))
-> [ByteString] -> m (f ClusterSlotsResponse)
forall a b. (a -> b) -> a -> b
$ [ByteString
"CLUSTER", ByteString
"SLOTS"]
data ClusterSlotStatsMetric
= ClusterSlotStatsKeyCount
| ClusterSlotStatsCpuUsec
| ClusterSlotStatsMemoryBytes
| ClusterSlotStatsNetworkBytesIn
| ClusterSlotStatsNetworkBytesOut
deriving (Int -> ClusterSlotStatsMetric -> ShowS
[ClusterSlotStatsMetric] -> ShowS
ClusterSlotStatsMetric -> String
(Int -> ClusterSlotStatsMetric -> ShowS)
-> (ClusterSlotStatsMetric -> String)
-> ([ClusterSlotStatsMetric] -> ShowS)
-> Show ClusterSlotStatsMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterSlotStatsMetric -> ShowS
showsPrec :: Int -> ClusterSlotStatsMetric -> ShowS
$cshow :: ClusterSlotStatsMetric -> String
show :: ClusterSlotStatsMetric -> String
$cshowList :: [ClusterSlotStatsMetric] -> ShowS
showList :: [ClusterSlotStatsMetric] -> ShowS
Show, ClusterSlotStatsMetric -> ClusterSlotStatsMetric -> Bool
(ClusterSlotStatsMetric -> ClusterSlotStatsMetric -> Bool)
-> (ClusterSlotStatsMetric -> ClusterSlotStatsMetric -> Bool)
-> Eq ClusterSlotStatsMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterSlotStatsMetric -> ClusterSlotStatsMetric -> Bool
== :: ClusterSlotStatsMetric -> ClusterSlotStatsMetric -> Bool
$c/= :: ClusterSlotStatsMetric -> ClusterSlotStatsMetric -> Bool
/= :: ClusterSlotStatsMetric -> ClusterSlotStatsMetric -> Bool
Eq)
instance RedisArg ClusterSlotStatsMetric where
encode :: ClusterSlotStatsMetric -> ByteString
encode ClusterSlotStatsMetric
ClusterSlotStatsKeyCount = ByteString
"KEY-COUNT"
encode ClusterSlotStatsMetric
ClusterSlotStatsCpuUsec = ByteString
"CPU-USEC"
encode ClusterSlotStatsMetric
ClusterSlotStatsMemoryBytes = ByteString
"MEMORY-BYTES"
encode ClusterSlotStatsMetric
ClusterSlotStatsNetworkBytesIn = ByteString
"NETWORK-BYTES-IN"
encode ClusterSlotStatsMetric
ClusterSlotStatsNetworkBytesOut = ByteString
"NETWORK-BYTES-OUT"
data ClusterSlotStatsOrderByOpts = ClusterSlotStatsOrderByOpts
{ ClusterSlotStatsOrderByOpts -> Maybe Integer
clusterSlotStatsOrderByLimit :: Maybe Integer
, ClusterSlotStatsOrderByOpts -> SortOrder
clusterSlotStatsOrderByDirection :: SortOrder
} deriving (Int -> ClusterSlotStatsOrderByOpts -> ShowS
[ClusterSlotStatsOrderByOpts] -> ShowS
ClusterSlotStatsOrderByOpts -> String
(Int -> ClusterSlotStatsOrderByOpts -> ShowS)
-> (ClusterSlotStatsOrderByOpts -> String)
-> ([ClusterSlotStatsOrderByOpts] -> ShowS)
-> Show ClusterSlotStatsOrderByOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterSlotStatsOrderByOpts -> ShowS
showsPrec :: Int -> ClusterSlotStatsOrderByOpts -> ShowS
$cshow :: ClusterSlotStatsOrderByOpts -> String
show :: ClusterSlotStatsOrderByOpts -> String
$cshowList :: [ClusterSlotStatsOrderByOpts] -> ShowS
showList :: [ClusterSlotStatsOrderByOpts] -> ShowS
Show, ClusterSlotStatsOrderByOpts -> ClusterSlotStatsOrderByOpts -> Bool
(ClusterSlotStatsOrderByOpts
-> ClusterSlotStatsOrderByOpts -> Bool)
-> (ClusterSlotStatsOrderByOpts
-> ClusterSlotStatsOrderByOpts -> Bool)
-> Eq ClusterSlotStatsOrderByOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterSlotStatsOrderByOpts -> ClusterSlotStatsOrderByOpts -> Bool
== :: ClusterSlotStatsOrderByOpts -> ClusterSlotStatsOrderByOpts -> Bool
$c/= :: ClusterSlotStatsOrderByOpts -> ClusterSlotStatsOrderByOpts -> Bool
/= :: ClusterSlotStatsOrderByOpts -> ClusterSlotStatsOrderByOpts -> Bool
Eq)
defaultClusterSlotStatsOrderByOpts :: ClusterSlotStatsOrderByOpts
defaultClusterSlotStatsOrderByOpts :: ClusterSlotStatsOrderByOpts
defaultClusterSlotStatsOrderByOpts = ClusterSlotStatsOrderByOpts
{ clusterSlotStatsOrderByLimit :: Maybe Integer
clusterSlotStatsOrderByLimit = Maybe Integer
forall a. Maybe a
Nothing
, clusterSlotStatsOrderByDirection :: SortOrder
clusterSlotStatsOrderByDirection = SortOrder
Desc
}
data ClusterSlotStatsQuery
= ClusterSlotStatsSlotsRange Integer Integer
| ClusterSlotStatsOrderBy ClusterSlotStatsMetric ClusterSlotStatsOrderByOpts
deriving (Int -> ClusterSlotStatsQuery -> ShowS
[ClusterSlotStatsQuery] -> ShowS
ClusterSlotStatsQuery -> String
(Int -> ClusterSlotStatsQuery -> ShowS)
-> (ClusterSlotStatsQuery -> String)
-> ([ClusterSlotStatsQuery] -> ShowS)
-> Show ClusterSlotStatsQuery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterSlotStatsQuery -> ShowS
showsPrec :: Int -> ClusterSlotStatsQuery -> ShowS
$cshow :: ClusterSlotStatsQuery -> String
show :: ClusterSlotStatsQuery -> String
$cshowList :: [ClusterSlotStatsQuery] -> ShowS
showList :: [ClusterSlotStatsQuery] -> ShowS
Show, ClusterSlotStatsQuery -> ClusterSlotStatsQuery -> Bool
(ClusterSlotStatsQuery -> ClusterSlotStatsQuery -> Bool)
-> (ClusterSlotStatsQuery -> ClusterSlotStatsQuery -> Bool)
-> Eq ClusterSlotStatsQuery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterSlotStatsQuery -> ClusterSlotStatsQuery -> Bool
== :: ClusterSlotStatsQuery -> ClusterSlotStatsQuery -> Bool
$c/= :: ClusterSlotStatsQuery -> ClusterSlotStatsQuery -> Bool
/= :: ClusterSlotStatsQuery -> ClusterSlotStatsQuery -> Bool
Eq)
data ClusterSlotStatsResponse = ClusterSlotStatsResponse
{ ClusterSlotStatsResponse -> [ClusterSlotStatsResponseEntry]
clusterSlotStatsResponseEntries :: [ClusterSlotStatsResponseEntry]
} deriving (Int -> ClusterSlotStatsResponse -> ShowS
[ClusterSlotStatsResponse] -> ShowS
ClusterSlotStatsResponse -> String
(Int -> ClusterSlotStatsResponse -> ShowS)
-> (ClusterSlotStatsResponse -> String)
-> ([ClusterSlotStatsResponse] -> ShowS)
-> Show ClusterSlotStatsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterSlotStatsResponse -> ShowS
showsPrec :: Int -> ClusterSlotStatsResponse -> ShowS
$cshow :: ClusterSlotStatsResponse -> String
show :: ClusterSlotStatsResponse -> String
$cshowList :: [ClusterSlotStatsResponse] -> ShowS
showList :: [ClusterSlotStatsResponse] -> ShowS
Show, ClusterSlotStatsResponse -> ClusterSlotStatsResponse -> Bool
(ClusterSlotStatsResponse -> ClusterSlotStatsResponse -> Bool)
-> (ClusterSlotStatsResponse -> ClusterSlotStatsResponse -> Bool)
-> Eq ClusterSlotStatsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterSlotStatsResponse -> ClusterSlotStatsResponse -> Bool
== :: ClusterSlotStatsResponse -> ClusterSlotStatsResponse -> Bool
$c/= :: ClusterSlotStatsResponse -> ClusterSlotStatsResponse -> Bool
/= :: ClusterSlotStatsResponse -> ClusterSlotStatsResponse -> Bool
Eq)
data ClusterSlotStatsResponseEntry = ClusterSlotStatsResponseEntry
{ ClusterSlotStatsResponseEntry -> Integer
clusterSlotStatsResponseEntrySlot :: Integer
, ClusterSlotStatsResponseEntry -> Maybe Integer
clusterSlotStatsResponseEntryKeyCount :: Maybe Integer
, ClusterSlotStatsResponseEntry -> Maybe Integer
clusterSlotStatsResponseEntryCpuUsec :: Maybe Integer
, ClusterSlotStatsResponseEntry -> Maybe Integer
clusterSlotStatsResponseEntryMemoryBytes :: Maybe Integer
, ClusterSlotStatsResponseEntry -> Maybe Integer
clusterSlotStatsResponseEntryNetworkBytesIn :: Maybe Integer
, ClusterSlotStatsResponseEntry -> Maybe Integer
clusterSlotStatsResponseEntryNetworkBytesOut :: Maybe Integer
} deriving (Int -> ClusterSlotStatsResponseEntry -> ShowS
[ClusterSlotStatsResponseEntry] -> ShowS
ClusterSlotStatsResponseEntry -> String
(Int -> ClusterSlotStatsResponseEntry -> ShowS)
-> (ClusterSlotStatsResponseEntry -> String)
-> ([ClusterSlotStatsResponseEntry] -> ShowS)
-> Show ClusterSlotStatsResponseEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterSlotStatsResponseEntry -> ShowS
showsPrec :: Int -> ClusterSlotStatsResponseEntry -> ShowS
$cshow :: ClusterSlotStatsResponseEntry -> String
show :: ClusterSlotStatsResponseEntry -> String
$cshowList :: [ClusterSlotStatsResponseEntry] -> ShowS
showList :: [ClusterSlotStatsResponseEntry] -> ShowS
Show, ClusterSlotStatsResponseEntry
-> ClusterSlotStatsResponseEntry -> Bool
(ClusterSlotStatsResponseEntry
-> ClusterSlotStatsResponseEntry -> Bool)
-> (ClusterSlotStatsResponseEntry
-> ClusterSlotStatsResponseEntry -> Bool)
-> Eq ClusterSlotStatsResponseEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterSlotStatsResponseEntry
-> ClusterSlotStatsResponseEntry -> Bool
== :: ClusterSlotStatsResponseEntry
-> ClusterSlotStatsResponseEntry -> Bool
$c/= :: ClusterSlotStatsResponseEntry
-> ClusterSlotStatsResponseEntry -> Bool
/= :: ClusterSlotStatsResponseEntry
-> ClusterSlotStatsResponseEntry -> Bool
Eq)
instance RedisResult ClusterSlotStatsResponse where
decode :: Reply -> Either Reply ClusterSlotStatsResponse
decode (MultiBulk (Just [Reply]
entries)) =
[ClusterSlotStatsResponseEntry] -> ClusterSlotStatsResponse
ClusterSlotStatsResponse ([ClusterSlotStatsResponseEntry] -> ClusterSlotStatsResponse)
-> Either Reply [ClusterSlotStatsResponseEntry]
-> Either Reply ClusterSlotStatsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Reply -> Either Reply ClusterSlotStatsResponseEntry)
-> [Reply] -> Either Reply [ClusterSlotStatsResponseEntry]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply ClusterSlotStatsResponseEntry
forall a. RedisResult a => Reply -> Either Reply a
decode [Reply]
entries
decode Reply
r = Reply -> Either Reply ClusterSlotStatsResponse
forall a b. a -> Either a b
Left Reply
r
instance RedisResult ClusterSlotStatsResponseEntry where
decode :: Reply -> Either Reply ClusterSlotStatsResponseEntry
decode r :: Reply
r@(MultiBulk (Just [Reply]
entries)) =
[Reply] -> Either Reply ClusterSlotStatsResponseEntry
parseClusterSlotStatsEntry [Reply]
entries
where
parseClusterSlotStatsEntry :: [Reply] -> Either Reply ClusterSlotStatsResponseEntry
parseClusterSlotStatsEntry :: [Reply] -> Either Reply ClusterSlotStatsResponseEntry
parseClusterSlotStatsEntry ((Integer Integer
slot):Reply
statsReply:[]) =
Integer
-> [(ByteString, Integer)]
-> Either Reply ClusterSlotStatsResponseEntry
parseClusterSlotStatsFields Integer
slot ([(ByteString, Integer)]
-> Either Reply ClusterSlotStatsResponseEntry)
-> Either Reply [(ByteString, Integer)]
-> Either Reply ClusterSlotStatsResponseEntry
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Reply -> Either Reply [(ByteString, Integer)]
parseClusterSlotStatsMetricPairs Reply
statsReply
parseClusterSlotStatsEntry [Reply]
fields =
case [Reply] -> Either Reply [(ByteString, Integer)]
parseClusterSlotStatsFieldPairs [Reply]
fields of
Right [(ByteString, Integer)]
kvs -> do
slot <- Either Reply Integer
-> (Integer -> Either Reply Integer)
-> Maybe Integer
-> Either Reply Integer
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Reply -> Either Reply Integer
forall a b. a -> Either a b
Left Reply
r) Integer -> Either Reply Integer
forall a b. b -> Either a b
Right (ByteString -> [(ByteString, Integer)] -> Maybe Integer
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
"slot" [(ByteString, Integer)]
kvs)
parseClusterSlotStatsFields slot (filter ((/= "slot") . fst) kvs)
Left Reply
_ -> Reply -> Either Reply ClusterSlotStatsResponseEntry
forall a b. a -> Either a b
Left Reply
r
parseClusterSlotStatsMetricPairs :: Reply -> Either Reply [(ByteString, Integer)]
parseClusterSlotStatsMetricPairs :: Reply -> Either Reply [(ByteString, Integer)]
parseClusterSlotStatsMetricPairs (MultiBulk (Just [Reply]
replies)) =
case [Reply] -> Either Reply [(ByteString, Integer)]
parseClusterSlotStatsFieldPairs [Reply]
replies of
Right [(ByteString, Integer)]
kvs -> [(ByteString, Integer)] -> Either Reply [(ByteString, Integer)]
forall a b. b -> Either a b
Right [(ByteString, Integer)]
kvs
Left Reply
_ -> (Reply -> Either Reply (ByteString, Integer))
-> [Reply] -> Either Reply [(ByteString, Integer)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply (ByteString, Integer)
forall {a} {a}.
(RedisResult a, RedisResult a) =>
Reply -> Either Reply (a, a)
parseNestedPair [Reply]
replies
where
parseNestedPair :: Reply -> Either Reply (a, a)
parseNestedPair (MultiBulk (Just [Reply
keyReply, Reply
valueReply])) =
(,) (a -> a -> (a, a)) -> Either Reply a -> Either Reply (a -> (a, a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
keyReply Either Reply (a -> (a, a)) -> Either Reply a -> Either Reply (a, a)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
valueReply
parseNestedPair Reply
nestedReply = Reply -> Either Reply (a, a)
forall a b. a -> Either a b
Left Reply
nestedReply
parseClusterSlotStatsMetricPairs Reply
reply' = Reply -> Either Reply [(ByteString, Integer)]
forall a b. a -> Either a b
Left Reply
reply'
parseClusterSlotStatsFieldPairs :: [Reply] -> Either Reply [(ByteString, Integer)]
parseClusterSlotStatsFieldPairs :: [Reply] -> Either Reply [(ByteString, Integer)]
parseClusterSlotStatsFieldPairs [] = [(ByteString, Integer)] -> Either Reply [(ByteString, Integer)]
forall a b. b -> Either a b
Right []
parseClusterSlotStatsFieldPairs (Reply
keyReply:Reply
valueReply:[Reply]
rest) =
(:) ((ByteString, Integer)
-> [(ByteString, Integer)] -> [(ByteString, Integer)])
-> Either Reply (ByteString, Integer)
-> Either
Reply ([(ByteString, Integer)] -> [(ByteString, Integer)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (ByteString -> Integer -> (ByteString, Integer))
-> Either Reply ByteString
-> Either Reply (Integer -> (ByteString, Integer))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
keyReply Either Reply (Integer -> (ByteString, Integer))
-> Either Reply Integer -> Either Reply (ByteString, Integer)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Integer
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
valueReply)
Either Reply ([(ByteString, Integer)] -> [(ByteString, Integer)])
-> Either Reply [(ByteString, Integer)]
-> Either Reply [(ByteString, Integer)]
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Reply] -> Either Reply [(ByteString, Integer)]
parseClusterSlotStatsFieldPairs [Reply]
rest
parseClusterSlotStatsFieldPairs [Reply
badReply] = Reply -> Either Reply [(ByteString, Integer)]
forall a b. a -> Either a b
Left Reply
badReply
parseClusterSlotStatsFields :: Integer -> [(ByteString, Integer)] -> Either Reply ClusterSlotStatsResponseEntry
parseClusterSlotStatsFields :: Integer
-> [(ByteString, Integer)]
-> Either Reply ClusterSlotStatsResponseEntry
parseClusterSlotStatsFields Integer
slot [(ByteString, Integer)]
fields =
ClusterSlotStatsResponseEntry
-> Either Reply ClusterSlotStatsResponseEntry
forall a b. b -> Either a b
Right ClusterSlotStatsResponseEntry
{ clusterSlotStatsResponseEntrySlot :: Integer
clusterSlotStatsResponseEntrySlot = Integer
slot
, clusterSlotStatsResponseEntryKeyCount :: Maybe Integer
clusterSlotStatsResponseEntryKeyCount = ByteString -> [(ByteString, Integer)] -> Maybe Integer
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
"key-count" [(ByteString, Integer)]
fields
, clusterSlotStatsResponseEntryCpuUsec :: Maybe Integer
clusterSlotStatsResponseEntryCpuUsec = ByteString -> [(ByteString, Integer)] -> Maybe Integer
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
"cpu-usec" [(ByteString, Integer)]
fields
, clusterSlotStatsResponseEntryMemoryBytes :: Maybe Integer
clusterSlotStatsResponseEntryMemoryBytes = ByteString -> [(ByteString, Integer)] -> Maybe Integer
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
"memory-bytes" [(ByteString, Integer)]
fields
, clusterSlotStatsResponseEntryNetworkBytesIn :: Maybe Integer
clusterSlotStatsResponseEntryNetworkBytesIn = ByteString -> [(ByteString, Integer)] -> Maybe Integer
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
"network-bytes-in" [(ByteString, Integer)]
fields
, clusterSlotStatsResponseEntryNetworkBytesOut :: Maybe Integer
clusterSlotStatsResponseEntryNetworkBytesOut = ByteString -> [(ByteString, Integer)] -> Maybe Integer
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
"network-bytes-out" [(ByteString, Integer)]
fields
}
decode Reply
r = Reply -> Either Reply ClusterSlotStatsResponseEntry
forall a b. a -> Either a b
Left Reply
r
clusterSlotStats
:: (RedisCtx m f)
=> ClusterSlotStatsQuery
-> m (f ClusterSlotStatsResponse)
clusterSlotStats :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ClusterSlotStatsQuery -> m (f ClusterSlotStatsResponse)
clusterSlotStats ClusterSlotStatsQuery
query = [ByteString] -> m (f ClusterSlotStatsResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f ClusterSlotStatsResponse))
-> [ByteString] -> m (f ClusterSlotStatsResponse)
forall a b. (a -> b) -> a -> b
$ [ByteString
"CLUSTER", ByteString
"SLOT-STATS"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ClusterSlotStatsQuery -> [ByteString]
clusterSlotStatsQueryArgs ClusterSlotStatsQuery
query
clusterSlotStatsSlotsRange
:: (RedisCtx m f)
=> Integer
-> Integer
-> m (f ClusterSlotStatsResponse)
clusterSlotStatsSlotsRange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> Integer -> m (f ClusterSlotStatsResponse)
clusterSlotStatsSlotsRange Integer
startSlot Integer
endSlot =
ClusterSlotStatsQuery -> m (f ClusterSlotStatsResponse)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ClusterSlotStatsQuery -> m (f ClusterSlotStatsResponse)
clusterSlotStats (Integer -> Integer -> ClusterSlotStatsQuery
ClusterSlotStatsSlotsRange Integer
startSlot Integer
endSlot)
clusterSlotStatsOrderBy
:: (RedisCtx m f)
=> ClusterSlotStatsMetric
-> m (f ClusterSlotStatsResponse)
clusterSlotStatsOrderBy :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ClusterSlotStatsMetric -> m (f ClusterSlotStatsResponse)
clusterSlotStatsOrderBy ClusterSlotStatsMetric
metric =
ClusterSlotStatsMetric
-> ClusterSlotStatsOrderByOpts -> m (f ClusterSlotStatsResponse)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ClusterSlotStatsMetric
-> ClusterSlotStatsOrderByOpts -> m (f ClusterSlotStatsResponse)
clusterSlotStatsOrderByOpts ClusterSlotStatsMetric
metric ClusterSlotStatsOrderByOpts
defaultClusterSlotStatsOrderByOpts
clusterSlotStatsOrderByOpts
:: (RedisCtx m f)
=> ClusterSlotStatsMetric
-> ClusterSlotStatsOrderByOpts
-> m (f ClusterSlotStatsResponse)
clusterSlotStatsOrderByOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ClusterSlotStatsMetric
-> ClusterSlotStatsOrderByOpts -> m (f ClusterSlotStatsResponse)
clusterSlotStatsOrderByOpts ClusterSlotStatsMetric
metric ClusterSlotStatsOrderByOpts
opts =
ClusterSlotStatsQuery -> m (f ClusterSlotStatsResponse)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ClusterSlotStatsQuery -> m (f ClusterSlotStatsResponse)
clusterSlotStats (ClusterSlotStatsMetric
-> ClusterSlotStatsOrderByOpts -> ClusterSlotStatsQuery
ClusterSlotStatsOrderBy ClusterSlotStatsMetric
metric ClusterSlotStatsOrderByOpts
opts)
clusterSlotStatsQueryArgs :: ClusterSlotStatsQuery -> [ByteString]
clusterSlotStatsQueryArgs :: ClusterSlotStatsQuery -> [ByteString]
clusterSlotStatsQueryArgs ClusterSlotStatsQuery
query =
case ClusterSlotStatsQuery
query of
ClusterSlotStatsSlotsRange Integer
startSlot Integer
endSlot ->
[ByteString
"SLOTSRANGE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
startSlot, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
endSlot]
ClusterSlotStatsOrderBy ClusterSlotStatsMetric
metric ClusterSlotStatsOrderByOpts{Maybe Integer
SortOrder
clusterSlotStatsOrderByLimit :: ClusterSlotStatsOrderByOpts -> Maybe Integer
clusterSlotStatsOrderByDirection :: ClusterSlotStatsOrderByOpts -> SortOrder
clusterSlotStatsOrderByLimit :: Maybe Integer
clusterSlotStatsOrderByDirection :: SortOrder
..} ->
[ByteString
"ORDERBY", ClusterSlotStatsMetric -> ByteString
forall a. RedisArg a => a -> ByteString
encode ClusterSlotStatsMetric
metric]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
limit -> [ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
limit]) Maybe Integer
clusterSlotStatsOrderByLimit
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [case SortOrder
clusterSlotStatsOrderByDirection of
SortOrder
Asc -> ByteString
"ASC"
SortOrder
Desc -> ByteString
"DESC"
]
clusterSetSlotImporting
:: (RedisCtx m f)
=> Integer
-> ByteString
-> m (f Status)
clusterSetSlotImporting :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> ByteString -> m (f Status)
clusterSetSlotImporting Integer
slot ByteString
sourceNodeId = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$ [ByteString
"CLUSTER", ByteString
"SETSLOT", (Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
slot), ByteString
"IMPORTING", ByteString
sourceNodeId]
clusterSetSlotMigrating
:: (RedisCtx m f)
=> Integer
-> ByteString
-> m (f Status)
clusterSetSlotMigrating :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> ByteString -> m (f Status)
clusterSetSlotMigrating Integer
slot ByteString
destinationNodeId = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$ [ByteString
"CLUSTER", ByteString
"SETSLOT", (Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
slot), ByteString
"MIGRATING", ByteString
destinationNodeId]
clusterSetSlotStable
:: (RedisCtx m f)
=> Integer
-> m (f Status)
clusterSetSlotStable :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> m (f Status)
clusterSetSlotStable Integer
slot = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$ [ByteString
"CLUSTER", ByteString
"SETSLOT", ByteString
"STABLE", (Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
slot)]
clusterSetSlotNode
:: (RedisCtx m f)
=> Integer
-> ByteString
-> m (f Status)
clusterSetSlotNode :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> ByteString -> m (f Status)
clusterSetSlotNode Integer
slot ByteString
node = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLUSTER", ByteString
"SETSLOT", (Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
slot), ByteString
"NODE", ByteString
node]
clusterGetKeysInSlot
:: (RedisCtx m f)
=> Integer
-> Integer
-> m (f [ByteString])
clusterGetKeysInSlot :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Integer -> Integer -> m (f [ByteString])
clusterGetKeysInSlot Integer
slot Integer
count = [ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLUSTER", ByteString
"GETKEYSINSLOT", (Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
slot), (Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count)]
data ClusterMigrationSlotRange = ClusterMigrationSlotRange
{ ClusterMigrationSlotRange -> Integer
clusterMigrationSlotRangeStart :: Integer
, ClusterMigrationSlotRange -> Integer
clusterMigrationSlotRangeEnd :: Integer
} deriving (Int -> ClusterMigrationSlotRange -> ShowS
[ClusterMigrationSlotRange] -> ShowS
ClusterMigrationSlotRange -> String
(Int -> ClusterMigrationSlotRange -> ShowS)
-> (ClusterMigrationSlotRange -> String)
-> ([ClusterMigrationSlotRange] -> ShowS)
-> Show ClusterMigrationSlotRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterMigrationSlotRange -> ShowS
showsPrec :: Int -> ClusterMigrationSlotRange -> ShowS
$cshow :: ClusterMigrationSlotRange -> String
show :: ClusterMigrationSlotRange -> String
$cshowList :: [ClusterMigrationSlotRange] -> ShowS
showList :: [ClusterMigrationSlotRange] -> ShowS
Show, ClusterMigrationSlotRange -> ClusterMigrationSlotRange -> Bool
(ClusterMigrationSlotRange -> ClusterMigrationSlotRange -> Bool)
-> (ClusterMigrationSlotRange -> ClusterMigrationSlotRange -> Bool)
-> Eq ClusterMigrationSlotRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterMigrationSlotRange -> ClusterMigrationSlotRange -> Bool
== :: ClusterMigrationSlotRange -> ClusterMigrationSlotRange -> Bool
$c/= :: ClusterMigrationSlotRange -> ClusterMigrationSlotRange -> Bool
/= :: ClusterMigrationSlotRange -> ClusterMigrationSlotRange -> Bool
Eq)
data ClusterMigrationTask = ClusterMigrationTask
{ ClusterMigrationTask -> ByteString
clusterMigrationTaskId :: ByteString
, ClusterMigrationTask -> [ClusterMigrationSlotRange]
clusterMigrationTaskSlots :: [ClusterMigrationSlotRange]
, ClusterMigrationTask -> Maybe ByteString
clusterMigrationTaskSource :: Maybe ByteString
, ClusterMigrationTask -> Maybe ByteString
clusterMigrationTaskDest :: Maybe ByteString
, ClusterMigrationTask -> Maybe ByteString
clusterMigrationTaskOperation :: Maybe ByteString
, ClusterMigrationTask -> Maybe ByteString
clusterMigrationTaskState :: Maybe ByteString
, ClusterMigrationTask -> Maybe ByteString
clusterMigrationTaskLastError :: Maybe ByteString
, ClusterMigrationTask -> Maybe Integer
clusterMigrationTaskRetries :: Maybe Integer
, ClusterMigrationTask -> Maybe Integer
clusterMigrationTaskCreateTime :: Maybe Integer
, ClusterMigrationTask -> Maybe Integer
clusterMigrationTaskStartTime :: Maybe Integer
, ClusterMigrationTask -> Maybe Integer
clusterMigrationTaskEndTime :: Maybe Integer
, ClusterMigrationTask -> Maybe Integer
clusterMigrationTaskWritePauseMs :: Maybe Integer
} deriving (Int -> ClusterMigrationTask -> ShowS
[ClusterMigrationTask] -> ShowS
ClusterMigrationTask -> String
(Int -> ClusterMigrationTask -> ShowS)
-> (ClusterMigrationTask -> String)
-> ([ClusterMigrationTask] -> ShowS)
-> Show ClusterMigrationTask
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterMigrationTask -> ShowS
showsPrec :: Int -> ClusterMigrationTask -> ShowS
$cshow :: ClusterMigrationTask -> String
show :: ClusterMigrationTask -> String
$cshowList :: [ClusterMigrationTask] -> ShowS
showList :: [ClusterMigrationTask] -> ShowS
Show, ClusterMigrationTask -> ClusterMigrationTask -> Bool
(ClusterMigrationTask -> ClusterMigrationTask -> Bool)
-> (ClusterMigrationTask -> ClusterMigrationTask -> Bool)
-> Eq ClusterMigrationTask
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterMigrationTask -> ClusterMigrationTask -> Bool
== :: ClusterMigrationTask -> ClusterMigrationTask -> Bool
$c/= :: ClusterMigrationTask -> ClusterMigrationTask -> Bool
/= :: ClusterMigrationTask -> ClusterMigrationTask -> Bool
Eq)
newtype ClusterMigrationStatusResponse = ClusterMigrationStatusResponse
{ ClusterMigrationStatusResponse -> [ClusterMigrationTask]
clusterMigrationStatusTasks :: [ClusterMigrationTask]
} deriving (Int -> ClusterMigrationStatusResponse -> ShowS
[ClusterMigrationStatusResponse] -> ShowS
ClusterMigrationStatusResponse -> String
(Int -> ClusterMigrationStatusResponse -> ShowS)
-> (ClusterMigrationStatusResponse -> String)
-> ([ClusterMigrationStatusResponse] -> ShowS)
-> Show ClusterMigrationStatusResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClusterMigrationStatusResponse -> ShowS
showsPrec :: Int -> ClusterMigrationStatusResponse -> ShowS
$cshow :: ClusterMigrationStatusResponse -> String
show :: ClusterMigrationStatusResponse -> String
$cshowList :: [ClusterMigrationStatusResponse] -> ShowS
showList :: [ClusterMigrationStatusResponse] -> ShowS
Show, ClusterMigrationStatusResponse
-> ClusterMigrationStatusResponse -> Bool
(ClusterMigrationStatusResponse
-> ClusterMigrationStatusResponse -> Bool)
-> (ClusterMigrationStatusResponse
-> ClusterMigrationStatusResponse -> Bool)
-> Eq ClusterMigrationStatusResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClusterMigrationStatusResponse
-> ClusterMigrationStatusResponse -> Bool
== :: ClusterMigrationStatusResponse
-> ClusterMigrationStatusResponse -> Bool
$c/= :: ClusterMigrationStatusResponse
-> ClusterMigrationStatusResponse -> Bool
/= :: ClusterMigrationStatusResponse
-> ClusterMigrationStatusResponse -> Bool
Eq)
instance RedisResult ClusterMigrationStatusResponse where
decode :: Reply -> Either Reply ClusterMigrationStatusResponse
decode (MultiBulk (Just [Reply]
tasks)) =
[ClusterMigrationTask] -> ClusterMigrationStatusResponse
ClusterMigrationStatusResponse ([ClusterMigrationTask] -> ClusterMigrationStatusResponse)
-> Either Reply [ClusterMigrationTask]
-> Either Reply ClusterMigrationStatusResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Reply -> Either Reply ClusterMigrationTask)
-> [Reply] -> Either Reply [ClusterMigrationTask]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply ClusterMigrationTask
forall a. RedisResult a => Reply -> Either Reply a
decode [Reply]
tasks
decode Reply
r = Reply -> Either Reply ClusterMigrationStatusResponse
forall a b. a -> Either a b
Left Reply
r
instance RedisResult ClusterMigrationTask where
decode :: Reply -> Either Reply ClusterMigrationTask
decode r :: Reply
r@(MultiBulk (Just [Reply]
replies)) = do
pairs <- [Reply] -> Either Reply [(ByteString, Reply)]
parsePairs [Reply]
replies
clusterMigrationTaskId <- lookupRequired "id" pairs
clusterMigrationTaskSlots <- maybe (Right []) parseSlotsReply (lookup "slots" pairs)
let clusterMigrationTaskSource = ByteString -> [(ByteString, Reply)] -> Maybe ByteString
lookupMaybeByteString ByteString
"source" [(ByteString, Reply)]
pairs
let clusterMigrationTaskDest = ByteString -> [(ByteString, Reply)] -> Maybe ByteString
lookupMaybeByteString ByteString
"dest" [(ByteString, Reply)]
pairs
let clusterMigrationTaskOperation = ByteString -> [(ByteString, Reply)] -> Maybe ByteString
lookupMaybeByteString ByteString
"operation" [(ByteString, Reply)]
pairs
let clusterMigrationTaskState = ByteString -> [(ByteString, Reply)] -> Maybe ByteString
lookupMaybeByteString ByteString
"state" [(ByteString, Reply)]
pairs
let clusterMigrationTaskLastError = ByteString -> [(ByteString, Reply)] -> Maybe ByteString
lookupMaybeByteString ByteString
"last_error" [(ByteString, Reply)]
pairs
let clusterMigrationTaskRetries = ByteString -> [(ByteString, Reply)] -> Maybe Integer
lookupInteger ByteString
"retries" [(ByteString, Reply)]
pairs
let clusterMigrationTaskCreateTime = ByteString -> [(ByteString, Reply)] -> Maybe Integer
lookupInteger ByteString
"create_time" [(ByteString, Reply)]
pairs
let clusterMigrationTaskStartTime = ByteString -> [(ByteString, Reply)] -> Maybe Integer
lookupInteger ByteString
"start_time" [(ByteString, Reply)]
pairs
let clusterMigrationTaskEndTime = ByteString -> [(ByteString, Reply)] -> Maybe Integer
lookupInteger ByteString
"end_time" [(ByteString, Reply)]
pairs
let clusterMigrationTaskWritePauseMs = ByteString -> [(ByteString, Reply)] -> Maybe Integer
lookupInteger ByteString
"write_pause_ms" [(ByteString, Reply)]
pairs
Right ClusterMigrationTask{..}
where
parsePairs :: [Reply] -> Either Reply [(ByteString, Reply)]
parsePairs :: [Reply] -> Either Reply [(ByteString, Reply)]
parsePairs [] = [(ByteString, Reply)] -> Either Reply [(ByteString, Reply)]
forall a b. b -> Either a b
Right []
parsePairs (Reply
keyReply:Reply
valueReply:[Reply]
rest) =
(:) ((ByteString, Reply)
-> [(ByteString, Reply)] -> [(ByteString, Reply)])
-> Either Reply (ByteString, Reply)
-> Either Reply ([(ByteString, Reply)] -> [(ByteString, Reply)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (ByteString -> Reply -> (ByteString, Reply))
-> Either Reply ByteString
-> Either Reply (Reply -> (ByteString, Reply))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
keyReply Either Reply (Reply -> (ByteString, Reply))
-> Either Reply Reply -> Either Reply (ByteString, Reply)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Reply
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Reply
valueReply) Either Reply ([(ByteString, Reply)] -> [(ByteString, Reply)])
-> Either Reply [(ByteString, Reply)]
-> Either Reply [(ByteString, Reply)]
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Reply] -> Either Reply [(ByteString, Reply)]
parsePairs [Reply]
rest
parsePairs [Reply
nestedReply] =
case Reply
nestedReply of
MultiBulk (Just [Reply]
nestedReplies) -> [Reply] -> Either Reply [(ByteString, Reply)]
parseNestedPairs [Reply]
nestedReplies
Reply
_ -> Reply -> Either Reply [(ByteString, Reply)]
forall a b. a -> Either a b
Left Reply
nestedReply
parseNestedPairs :: [Reply] -> Either Reply [(ByteString, Reply)]
parseNestedPairs :: [Reply] -> Either Reply [(ByteString, Reply)]
parseNestedPairs [Reply]
nestedReplies = (Reply -> Either Reply (ByteString, Reply))
-> [Reply] -> Either Reply [(ByteString, Reply)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply (ByteString, Reply)
parseNestedPair [Reply]
nestedReplies
parseNestedPair :: Reply -> Either Reply (ByteString, Reply)
parseNestedPair :: Reply -> Either Reply (ByteString, Reply)
parseNestedPair (MultiBulk (Just [Reply
keyReply, Reply
valueReply])) =
(,) (ByteString -> Reply -> (ByteString, Reply))
-> Either Reply ByteString
-> Either Reply (Reply -> (ByteString, Reply))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply ByteString
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
keyReply Either Reply (Reply -> (ByteString, Reply))
-> Either Reply Reply -> Either Reply (ByteString, Reply)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Reply
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Reply
valueReply
parseNestedPair Reply
nestedReply = Reply -> Either Reply (ByteString, Reply)
forall a b. a -> Either a b
Left Reply
nestedReply
lookupRequired :: RedisResult a => ByteString -> [(ByteString, Reply)] -> Either Reply a
lookupRequired :: forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Either Reply a
lookupRequired ByteString
key [(ByteString, Reply)]
pairs =
Either Reply a
-> (Reply -> Either Reply a) -> Maybe Reply -> Either Reply a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Reply -> Either Reply a
forall a b. a -> Either a b
Left Reply
r) Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode (ByteString -> [(ByteString, Reply)] -> Maybe Reply
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
key [(ByteString, Reply)]
pairs)
lookupMaybeByteString :: ByteString -> [(ByteString, Reply)] -> Maybe ByteString
lookupMaybeByteString :: ByteString -> [(ByteString, Reply)] -> Maybe ByteString
lookupMaybeByteString ByteString
key [(ByteString, Reply)]
pairs =
case ByteString -> [(ByteString, Reply)] -> Maybe Reply
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
key [(ByteString, Reply)]
pairs of
Just (Bulk (Just ByteString
"")) -> Maybe ByteString
forall a. Maybe a
Nothing
Just Reply
valueReply -> (Reply -> Maybe ByteString)
-> (Maybe ByteString -> Maybe ByteString)
-> Either Reply (Maybe ByteString)
-> Maybe ByteString
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe ByteString -> Reply -> Maybe ByteString
forall a b. a -> b -> a
const Maybe ByteString
forall a. Maybe a
Nothing) Maybe ByteString -> Maybe ByteString
forall a. a -> a
id (Reply -> Either Reply (Maybe ByteString)
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
valueReply)
Maybe Reply
Nothing -> Maybe ByteString
forall a. Maybe a
Nothing
lookupInteger :: ByteString -> [(ByteString, Reply)] -> Maybe Integer
lookupInteger :: ByteString -> [(ByteString, Reply)] -> Maybe Integer
lookupInteger ByteString
key [(ByteString, Reply)]
pairs =
case ByteString -> [(ByteString, Reply)] -> Maybe Reply
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
key [(ByteString, Reply)]
pairs of
Just Reply
valueReply -> (Reply -> Maybe Integer)
-> (Integer -> Maybe Integer)
-> Either Reply Integer
-> Maybe Integer
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe Integer -> Reply -> Maybe Integer
forall a b. a -> b -> a
const Maybe Integer
forall a. Maybe a
Nothing) Integer -> Maybe Integer
forall a. a -> Maybe a
Just (Reply -> Either Reply Integer
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
valueReply)
Maybe Reply
Nothing -> Maybe Integer
forall a. Maybe a
Nothing
parseSlotsReply :: Reply -> Either Reply [ClusterMigrationSlotRange]
parseSlotsReply :: Reply -> Either Reply [ClusterMigrationSlotRange]
parseSlotsReply (Bulk (Just ByteString
slotRanges)) =
(ByteString -> Either Reply ClusterMigrationSlotRange)
-> [ByteString] -> Either Reply [ClusterMigrationSlotRange]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM ByteString -> Either Reply ClusterMigrationSlotRange
parseSlotToken (ByteString -> [ByteString]
Char8.words (ByteString -> [ByteString]) -> ByteString -> [ByteString]
forall a b. (a -> b) -> a -> b
$ (Char -> Char) -> ByteString -> ByteString
Char8.map Char -> Char
normalizeDelimiter ByteString
slotRanges)
where
normalizeDelimiter :: Char -> Char
normalizeDelimiter Char
',' = Char
' '
normalizeDelimiter Char
c = Char
c
parseSlotsReply (MultiBulk (Just [Reply]
slotReplies))
| (Reply -> Bool) -> [Reply] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all Reply -> Bool
isIntegerReply [Reply]
slotReplies = [Reply] -> Either Reply [ClusterMigrationSlotRange]
parseIntegerPairs [Reply]
slotReplies
| Bool
otherwise = (Reply -> Either Reply ClusterMigrationSlotRange)
-> [Reply] -> Either Reply [ClusterMigrationSlotRange]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Reply -> Either Reply ClusterMigrationSlotRange
parseNestedRange [Reply]
slotReplies
where
isIntegerReply :: Reply -> Bool
isIntegerReply (Integer Integer
_) = Bool
True
isIntegerReply Reply
_ = Bool
False
parseIntegerPairs :: [Reply] -> Either Reply [ClusterMigrationSlotRange]
parseIntegerPairs :: [Reply] -> Either Reply [ClusterMigrationSlotRange]
parseIntegerPairs [] = [ClusterMigrationSlotRange]
-> Either Reply [ClusterMigrationSlotRange]
forall a b. b -> Either a b
Right []
parseIntegerPairs (Integer Integer
startSlot:Integer Integer
endSlot:[Reply]
rest) =
(Integer -> Integer -> ClusterMigrationSlotRange
ClusterMigrationSlotRange Integer
startSlot Integer
endSlot ClusterMigrationSlotRange
-> [ClusterMigrationSlotRange] -> [ClusterMigrationSlotRange]
forall a. a -> [a] -> [a]
:) ([ClusterMigrationSlotRange] -> [ClusterMigrationSlotRange])
-> Either Reply [ClusterMigrationSlotRange]
-> Either Reply [ClusterMigrationSlotRange]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Reply] -> Either Reply [ClusterMigrationSlotRange]
parseIntegerPairs [Reply]
rest
parseIntegerPairs [Reply]
badReplies = Reply -> Either Reply [ClusterMigrationSlotRange]
forall a b. a -> Either a b
Left (Reply -> Either Reply [ClusterMigrationSlotRange])
-> Reply -> Either Reply [ClusterMigrationSlotRange]
forall a b. (a -> b) -> a -> b
$ Maybe [Reply] -> Reply
MultiBulk ([Reply] -> Maybe [Reply]
forall a. a -> Maybe a
Just [Reply]
badReplies)
parseNestedRange :: Reply -> Either Reply ClusterMigrationSlotRange
parseNestedRange :: Reply -> Either Reply ClusterMigrationSlotRange
parseNestedRange (MultiBulk (Just [Integer Integer
startSlot, Integer Integer
endSlot])) =
ClusterMigrationSlotRange -> Either Reply ClusterMigrationSlotRange
forall a b. b -> Either a b
Right (ClusterMigrationSlotRange
-> Either Reply ClusterMigrationSlotRange)
-> ClusterMigrationSlotRange
-> Either Reply ClusterMigrationSlotRange
forall a b. (a -> b) -> a -> b
$ Integer -> Integer -> ClusterMigrationSlotRange
ClusterMigrationSlotRange Integer
startSlot Integer
endSlot
parseNestedRange Reply
nestedReply = Reply -> Either Reply ClusterMigrationSlotRange
forall a b. a -> Either a b
Left Reply
nestedReply
parseSlotsReply Reply
badReply = Reply -> Either Reply [ClusterMigrationSlotRange]
forall a b. a -> Either a b
Left Reply
badReply
parseSlotToken :: ByteString -> Either Reply ClusterMigrationSlotRange
parseSlotToken :: ByteString -> Either Reply ClusterMigrationSlotRange
parseSlotToken ByteString
token =
case (Char -> Bool) -> ByteString -> (ByteString, ByteString)
Char8.break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'-') ByteString
token of
(ByteString
startPart, ByteString
endPart)
| ByteString -> Bool
BS.null ByteString
endPart -> do
startSlot <- ByteString -> Either Reply Integer
parseIntegerToken ByteString
token
Right $ ClusterMigrationSlotRange startSlot startSlot
| Bool
otherwise -> do
startSlot <- ByteString -> Either Reply Integer
parseIntegerToken ByteString
startPart
endSlot <- parseIntegerToken (Char8.drop 1 endPart)
Right $ ClusterMigrationSlotRange startSlot endSlot
parseIntegerToken :: ByteString -> Either Reply Integer
parseIntegerToken :: ByteString -> Either Reply Integer
parseIntegerToken ByteString
token =
Either Reply Integer
-> (Integer -> Either Reply Integer)
-> Maybe Integer
-> Either Reply Integer
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Reply -> Either Reply Integer
forall a b. a -> Either a b
Left Reply
r) Integer -> Either Reply Integer
forall a b. b -> Either a b
Right ((Integer, ByteString) -> Integer
forall a b. (a, b) -> a
fst ((Integer, ByteString) -> Integer)
-> Maybe (Integer, ByteString) -> Maybe Integer
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ByteString -> Maybe (Integer, ByteString)
Char8.readInteger ByteString
token)
decode Reply
r = Reply -> Either Reply ClusterMigrationTask
forall a b. a -> Either a b
Left Reply
r
clusterMigrationImport
:: (RedisCtx m f)
=> NonEmpty (Integer, Integer)
-> m (f ByteString)
clusterMigrationImport :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty (Integer, Integer) -> m (f ByteString)
clusterMigrationImport NonEmpty (Integer, Integer)
slotRanges =
[ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f ByteString))
-> [ByteString] -> m (f ByteString)
forall a b. (a -> b) -> a -> b
$ [ByteString
"CLUSTER", ByteString
"MIGRATION", ByteString
"IMPORT"]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ((Integer, Integer) -> [ByteString])
-> [(Integer, Integer)] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (\(Integer
startSlot, Integer
endSlot) -> [Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
startSlot, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
endSlot]) (NonEmpty (Integer, Integer) -> [(Integer, Integer)]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty (Integer, Integer)
slotRanges)
clusterMigrationCancelId
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
clusterMigrationCancelId :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
clusterMigrationCancelId ByteString
taskId =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLUSTER", ByteString
"MIGRATION", ByteString
"CANCEL", ByteString
"ID", ByteString
taskId]
clusterMigrationCancelAll
:: (RedisCtx m f)
=> m (f Integer)
clusterMigrationCancelAll :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Integer)
clusterMigrationCancelAll =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLUSTER", ByteString
"MIGRATION", ByteString
"CANCEL", ByteString
"ALL"]
clusterMigrationStatus
:: (RedisCtx m f)
=> m (f ClusterMigrationStatusResponse)
clusterMigrationStatus :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f ClusterMigrationStatusResponse)
clusterMigrationStatus =
[ByteString] -> m (f ClusterMigrationStatusResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLUSTER", ByteString
"MIGRATION", ByteString
"STATUS"]
clusterMigrationStatusAll
:: (RedisCtx m f)
=> m (f ClusterMigrationStatusResponse)
clusterMigrationStatusAll :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f ClusterMigrationStatusResponse)
clusterMigrationStatusAll =
[ByteString] -> m (f ClusterMigrationStatusResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLUSTER", ByteString
"MIGRATION", ByteString
"STATUS", ByteString
"ALL"]
clusterMigrationStatusId
:: (RedisCtx m f)
=> ByteString
-> m (f ClusterMigrationStatusResponse)
clusterMigrationStatusId :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ClusterMigrationStatusResponse)
clusterMigrationStatusId ByteString
taskId =
[ByteString] -> m (f ClusterMigrationStatusResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"CLUSTER", ByteString
"MIGRATION", ByteString
"STATUS", ByteString
"ID", ByteString
taskId]
command :: (RedisCtx m f) => m (f [CMD.CommandInfo])
command :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f [CommandInfo])
command = [ByteString] -> m (f [CommandInfo])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"COMMAND"]
commandList
:: (RedisCtx m f)
=> m (f [ByteString])
commandList :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f [ByteString])
commandList = Maybe CommandListFilter -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Maybe CommandListFilter -> m (f [ByteString])
commandListOpts Maybe CommandListFilter
forall a. Maybe a
Nothing
data CommandListFilter
= CommandListFilterByModule ByteString
| CommandListFilterByAclCat ByteString
| CommandListFilterByPattern ByteString
deriving (Int -> CommandListFilter -> ShowS
[CommandListFilter] -> ShowS
CommandListFilter -> String
(Int -> CommandListFilter -> ShowS)
-> (CommandListFilter -> String)
-> ([CommandListFilter] -> ShowS)
-> Show CommandListFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommandListFilter -> ShowS
showsPrec :: Int -> CommandListFilter -> ShowS
$cshow :: CommandListFilter -> String
show :: CommandListFilter -> String
$cshowList :: [CommandListFilter] -> ShowS
showList :: [CommandListFilter] -> ShowS
Show, CommandListFilter -> CommandListFilter -> Bool
(CommandListFilter -> CommandListFilter -> Bool)
-> (CommandListFilter -> CommandListFilter -> Bool)
-> Eq CommandListFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CommandListFilter -> CommandListFilter -> Bool
== :: CommandListFilter -> CommandListFilter -> Bool
$c/= :: CommandListFilter -> CommandListFilter -> Bool
/= :: CommandListFilter -> CommandListFilter -> Bool
Eq)
commandListOpts
:: (RedisCtx m f)
=> Maybe CommandListFilter
-> m (f [ByteString])
commandListOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
Maybe CommandListFilter -> m (f [ByteString])
commandListOpts Maybe CommandListFilter
commandFilter =
[ByteString] -> m (f [ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [ByteString]))
-> [ByteString] -> m (f [ByteString])
forall a b. (a -> b) -> a -> b
$ [ByteString
"COMMAND", ByteString
"LIST"] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
filterArgs
where
filterArgs :: [ByteString]
filterArgs =
case Maybe CommandListFilter
commandFilter of
Maybe CommandListFilter
Nothing -> []
Just (CommandListFilterByModule ByteString
moduleName) ->
[ByteString
"FILTERBY", ByteString
"MODULE", ByteString
moduleName]
Just (CommandListFilterByAclCat ByteString
category) ->
[ByteString
"FILTERBY", ByteString
"ACLCAT", ByteString
category]
Just (CommandListFilterByPattern ByteString
pattern_) ->
[ByteString
"FILTERBY", ByteString
"PATTERN", ByteString
pattern_]
data IncrexExpiration
= IncrexSeconds Integer
| IncrexMilliseconds Integer
| IncrexUnixSeconds Integer
| IncrexUnixMilliseconds Integer
| IncrexPersist
deriving (Int -> IncrexExpiration -> ShowS
[IncrexExpiration] -> ShowS
IncrexExpiration -> String
(Int -> IncrexExpiration -> ShowS)
-> (IncrexExpiration -> String)
-> ([IncrexExpiration] -> ShowS)
-> Show IncrexExpiration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> IncrexExpiration -> ShowS
showsPrec :: Int -> IncrexExpiration -> ShowS
$cshow :: IncrexExpiration -> String
show :: IncrexExpiration -> String
$cshowList :: [IncrexExpiration] -> ShowS
showList :: [IncrexExpiration] -> ShowS
Show, IncrexExpiration -> IncrexExpiration -> Bool
(IncrexExpiration -> IncrexExpiration -> Bool)
-> (IncrexExpiration -> IncrexExpiration -> Bool)
-> Eq IncrexExpiration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: IncrexExpiration -> IncrexExpiration -> Bool
== :: IncrexExpiration -> IncrexExpiration -> Bool
$c/= :: IncrexExpiration -> IncrexExpiration -> Bool
/= :: IncrexExpiration -> IncrexExpiration -> Bool
Eq)
data IncrexOpts a = IncrexOpts
{ forall a. IncrexOpts a -> Maybe a
increxLowerBound :: Maybe a
, forall a. IncrexOpts a -> Maybe a
increxUpperBound :: Maybe a
, forall a. IncrexOpts a -> Bool
increxSaturate :: Bool
, forall a. IncrexOpts a -> Maybe IncrexExpiration
increxExpiration :: Maybe IncrexExpiration
, forall a. IncrexOpts a -> Bool
increxExpirationIfNotExists :: Bool
} deriving (Int -> IncrexOpts a -> ShowS
[IncrexOpts a] -> ShowS
IncrexOpts a -> String
(Int -> IncrexOpts a -> ShowS)
-> (IncrexOpts a -> String)
-> ([IncrexOpts a] -> ShowS)
-> Show (IncrexOpts a)
forall a. Show a => Int -> IncrexOpts a -> ShowS
forall a. Show a => [IncrexOpts a] -> ShowS
forall a. Show a => IncrexOpts a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> IncrexOpts a -> ShowS
showsPrec :: Int -> IncrexOpts a -> ShowS
$cshow :: forall a. Show a => IncrexOpts a -> String
show :: IncrexOpts a -> String
$cshowList :: forall a. Show a => [IncrexOpts a] -> ShowS
showList :: [IncrexOpts a] -> ShowS
Show, IncrexOpts a -> IncrexOpts a -> Bool
(IncrexOpts a -> IncrexOpts a -> Bool)
-> (IncrexOpts a -> IncrexOpts a -> Bool) -> Eq (IncrexOpts a)
forall a. Eq a => IncrexOpts a -> IncrexOpts a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall a. Eq a => IncrexOpts a -> IncrexOpts a -> Bool
== :: IncrexOpts a -> IncrexOpts a -> Bool
$c/= :: forall a. Eq a => IncrexOpts a -> IncrexOpts a -> Bool
/= :: IncrexOpts a -> IncrexOpts a -> Bool
Eq)
defaultIncrexOpts :: IncrexOpts a
defaultIncrexOpts :: forall a. IncrexOpts a
defaultIncrexOpts = IncrexOpts
{ increxLowerBound :: Maybe a
increxLowerBound = Maybe a
forall a. Maybe a
Nothing
, increxUpperBound :: Maybe a
increxUpperBound = Maybe a
forall a. Maybe a
Nothing
, increxSaturate :: Bool
increxSaturate = Bool
False
, increxExpiration :: Maybe IncrexExpiration
increxExpiration = Maybe IncrexExpiration
forall a. Maybe a
Nothing
, increxExpirationIfNotExists :: Bool
increxExpirationIfNotExists = Bool
False
}
increx
:: (RedisCtx m f)
=> ByteString
-> m (f (Integer, Integer))
increx :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Integer, Integer))
increx ByteString
key = ByteString -> IncrexOpts Integer -> m (f (Integer, Integer))
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> IncrexOpts Integer -> m (f (Integer, Integer))
increxOpts ByteString
key IncrexOpts Integer
forall a. IncrexOpts a
defaultIncrexOpts
increxOpts
:: (RedisCtx m f)
=> ByteString
-> IncrexOpts Integer
-> m (f (Integer, Integer))
increxOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> IncrexOpts Integer -> m (f (Integer, Integer))
increxOpts ByteString
key IncrexOpts Integer
opts =
[ByteString] -> m (f (Integer, Integer))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Integer, Integer)))
-> [ByteString] -> m (f (Integer, Integer))
forall a b. (a -> b) -> a -> b
$ [ByteString
"INCREX", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ IncrexOpts Integer -> [ByteString]
forall a. RedisArg a => IncrexOpts a -> [ByteString]
increxCommonArgs IncrexOpts Integer
opts
increxBy
:: (RedisCtx m f)
=> ByteString
-> Integer
-> IncrexOpts Integer
-> m (f (Integer, Integer))
increxBy :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer -> IncrexOpts Integer -> m (f (Integer, Integer))
increxBy ByteString
key Integer
increment IncrexOpts Integer
opts =
[ByteString] -> m (f (Integer, Integer))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Integer, Integer)))
-> [ByteString] -> m (f (Integer, Integer))
forall a b. (a -> b) -> a -> b
$ [ByteString
"INCREX", ByteString
key, ByteString
"BYINT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
increment] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ IncrexOpts Integer -> [ByteString]
forall a. RedisArg a => IncrexOpts a -> [ByteString]
increxCommonArgs IncrexOpts Integer
opts
increxByFloat
:: (RedisCtx m f)
=> ByteString
-> Double
-> IncrexOpts Double
-> m (f (Double, Double))
increxByFloat :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Double -> IncrexOpts Double -> m (f (Double, Double))
increxByFloat ByteString
key Double
increment IncrexOpts Double
opts =
[ByteString] -> m (f (Double, Double))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Double, Double)))
-> [ByteString] -> m (f (Double, Double))
forall a b. (a -> b) -> a -> b
$ [ByteString
"INCREX", ByteString
key, ByteString
"BYFLOAT", Double -> ByteString
forall a. RedisArg a => a -> ByteString
encode Double
increment] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ IncrexOpts Double -> [ByteString]
forall a. RedisArg a => IncrexOpts a -> [ByteString]
increxCommonArgs IncrexOpts Double
opts
increxCommonArgs :: RedisArg a => IncrexOpts a -> [ByteString]
increxCommonArgs :: forall a. RedisArg a => IncrexOpts a -> [ByteString]
increxCommonArgs IncrexOpts{Bool
Maybe a
Maybe IncrexExpiration
increxLowerBound :: forall a. IncrexOpts a -> Maybe a
increxUpperBound :: forall a. IncrexOpts a -> Maybe a
increxSaturate :: forall a. IncrexOpts a -> Bool
increxExpiration :: forall a. IncrexOpts a -> Maybe IncrexExpiration
increxExpirationIfNotExists :: forall a. IncrexOpts a -> Bool
increxLowerBound :: Maybe a
increxUpperBound :: Maybe a
increxSaturate :: Bool
increxExpiration :: Maybe IncrexExpiration
increxExpirationIfNotExists :: Bool
..} =
[ByteString]
lowerBoundArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
upperBoundArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
saturateArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
expirationArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
enxArg
where
lowerBoundArg :: [ByteString]
lowerBoundArg = [ByteString] -> (a -> [ByteString]) -> Maybe a -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\a
bound -> [ByteString
"LBOUND", a -> ByteString
forall a. RedisArg a => a -> ByteString
encode a
bound]) Maybe a
increxLowerBound
upperBoundArg :: [ByteString]
upperBoundArg = [ByteString] -> (a -> [ByteString]) -> Maybe a -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\a
bound -> [ByteString
"UBOUND", a -> ByteString
forall a. RedisArg a => a -> ByteString
encode a
bound]) Maybe a
increxUpperBound
saturateArg :: [ByteString]
saturateArg = [ByteString
"SATURATE" | Bool
increxSaturate]
expirationArg :: [ByteString]
expirationArg =
case Maybe IncrexExpiration
increxExpiration of
Maybe IncrexExpiration
Nothing -> []
Just (IncrexSeconds Integer
seconds) -> [ByteString
"EX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds]
Just (IncrexMilliseconds Integer
milliseconds) -> [ByteString
"PX", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds]
Just (IncrexUnixSeconds Integer
seconds) -> [ByteString
"EXAT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds]
Just (IncrexUnixMilliseconds Integer
milliseconds) -> [ByteString
"PXAT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
milliseconds]
Just IncrexExpiration
IncrexPersist -> [ByteString
"PERSIST"]
enxArg :: [ByteString]
enxArg = [ByteString
"ENX" | Bool
increxExpirationIfNotExists]
data ARGrepPredicate
= ARGrepExact ByteString
| ARGrepMatch ByteString
| ARGrepGlob ByteString
| ARGrepRegex ByteString
deriving (Int -> ARGrepPredicate -> ShowS
[ARGrepPredicate] -> ShowS
ARGrepPredicate -> String
(Int -> ARGrepPredicate -> ShowS)
-> (ARGrepPredicate -> String)
-> ([ARGrepPredicate] -> ShowS)
-> Show ARGrepPredicate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ARGrepPredicate -> ShowS
showsPrec :: Int -> ARGrepPredicate -> ShowS
$cshow :: ARGrepPredicate -> String
show :: ARGrepPredicate -> String
$cshowList :: [ARGrepPredicate] -> ShowS
showList :: [ARGrepPredicate] -> ShowS
Show, ARGrepPredicate -> ARGrepPredicate -> Bool
(ARGrepPredicate -> ARGrepPredicate -> Bool)
-> (ARGrepPredicate -> ARGrepPredicate -> Bool)
-> Eq ARGrepPredicate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ARGrepPredicate -> ARGrepPredicate -> Bool
== :: ARGrepPredicate -> ARGrepPredicate -> Bool
$c/= :: ARGrepPredicate -> ARGrepPredicate -> Bool
/= :: ARGrepPredicate -> ARGrepPredicate -> Bool
Eq)
data ARGrepCombine
= ARGrepAnd
| ARGrepOr
deriving (Int -> ARGrepCombine -> ShowS
[ARGrepCombine] -> ShowS
ARGrepCombine -> String
(Int -> ARGrepCombine -> ShowS)
-> (ARGrepCombine -> String)
-> ([ARGrepCombine] -> ShowS)
-> Show ARGrepCombine
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ARGrepCombine -> ShowS
showsPrec :: Int -> ARGrepCombine -> ShowS
$cshow :: ARGrepCombine -> String
show :: ARGrepCombine -> String
$cshowList :: [ARGrepCombine] -> ShowS
showList :: [ARGrepCombine] -> ShowS
Show, ARGrepCombine -> ARGrepCombine -> Bool
(ARGrepCombine -> ARGrepCombine -> Bool)
-> (ARGrepCombine -> ARGrepCombine -> Bool) -> Eq ARGrepCombine
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ARGrepCombine -> ARGrepCombine -> Bool
== :: ARGrepCombine -> ARGrepCombine -> Bool
$c/= :: ARGrepCombine -> ARGrepCombine -> Bool
/= :: ARGrepCombine -> ARGrepCombine -> Bool
Eq)
data ARGrepOpts = ARGrepOpts
{ ARGrepOpts -> Maybe ARGrepCombine
arGrepCombine :: Maybe ARGrepCombine
, ARGrepOpts -> Maybe Integer
arGrepLimit :: Maybe Integer
, ARGrepOpts -> Bool
arGrepNoCase :: Bool
} deriving (Int -> ARGrepOpts -> ShowS
[ARGrepOpts] -> ShowS
ARGrepOpts -> String
(Int -> ARGrepOpts -> ShowS)
-> (ARGrepOpts -> String)
-> ([ARGrepOpts] -> ShowS)
-> Show ARGrepOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ARGrepOpts -> ShowS
showsPrec :: Int -> ARGrepOpts -> ShowS
$cshow :: ARGrepOpts -> String
show :: ARGrepOpts -> String
$cshowList :: [ARGrepOpts] -> ShowS
showList :: [ARGrepOpts] -> ShowS
Show, ARGrepOpts -> ARGrepOpts -> Bool
(ARGrepOpts -> ARGrepOpts -> Bool)
-> (ARGrepOpts -> ARGrepOpts -> Bool) -> Eq ARGrepOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ARGrepOpts -> ARGrepOpts -> Bool
== :: ARGrepOpts -> ARGrepOpts -> Bool
$c/= :: ARGrepOpts -> ARGrepOpts -> Bool
/= :: ARGrepOpts -> ARGrepOpts -> Bool
Eq)
defaultARGrepOpts :: ARGrepOpts
defaultARGrepOpts :: ARGrepOpts
defaultARGrepOpts = ARGrepOpts
{ arGrepCombine :: Maybe ARGrepCombine
arGrepCombine = Maybe ARGrepCombine
forall a. Maybe a
Nothing
, arGrepLimit :: Maybe Integer
arGrepLimit = Maybe Integer
forall a. Maybe a
Nothing
, arGrepNoCase :: Bool
arGrepNoCase = Bool
False
}
data ARLastItemsOpts = ARLastItemsOpts
{ ARLastItemsOpts -> Bool
arLastItemsReverse :: Bool
} deriving (Int -> ARLastItemsOpts -> ShowS
[ARLastItemsOpts] -> ShowS
ARLastItemsOpts -> String
(Int -> ARLastItemsOpts -> ShowS)
-> (ARLastItemsOpts -> String)
-> ([ARLastItemsOpts] -> ShowS)
-> Show ARLastItemsOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ARLastItemsOpts -> ShowS
showsPrec :: Int -> ARLastItemsOpts -> ShowS
$cshow :: ARLastItemsOpts -> String
show :: ARLastItemsOpts -> String
$cshowList :: [ARLastItemsOpts] -> ShowS
showList :: [ARLastItemsOpts] -> ShowS
Show, ARLastItemsOpts -> ARLastItemsOpts -> Bool
(ARLastItemsOpts -> ARLastItemsOpts -> Bool)
-> (ARLastItemsOpts -> ARLastItemsOpts -> Bool)
-> Eq ARLastItemsOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ARLastItemsOpts -> ARLastItemsOpts -> Bool
== :: ARLastItemsOpts -> ARLastItemsOpts -> Bool
$c/= :: ARLastItemsOpts -> ARLastItemsOpts -> Bool
/= :: ARLastItemsOpts -> ARLastItemsOpts -> Bool
Eq)
defaultARLastItemsOpts :: ARLastItemsOpts
defaultARLastItemsOpts :: ARLastItemsOpts
defaultARLastItemsOpts = ARLastItemsOpts
{ arLastItemsReverse :: Bool
arLastItemsReverse = Bool
False
}
data ARScanOpts = ARScanOpts
{ ARScanOpts -> Maybe Integer
arScanLimit :: Maybe Integer
} deriving (Int -> ARScanOpts -> ShowS
[ARScanOpts] -> ShowS
ARScanOpts -> String
(Int -> ARScanOpts -> ShowS)
-> (ARScanOpts -> String)
-> ([ARScanOpts] -> ShowS)
-> Show ARScanOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ARScanOpts -> ShowS
showsPrec :: Int -> ARScanOpts -> ShowS
$cshow :: ARScanOpts -> String
show :: ARScanOpts -> String
$cshowList :: [ARScanOpts] -> ShowS
showList :: [ARScanOpts] -> ShowS
Show, ARScanOpts -> ARScanOpts -> Bool
(ARScanOpts -> ARScanOpts -> Bool)
-> (ARScanOpts -> ARScanOpts -> Bool) -> Eq ARScanOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ARScanOpts -> ARScanOpts -> Bool
== :: ARScanOpts -> ARScanOpts -> Bool
$c/= :: ARScanOpts -> ARScanOpts -> Bool
/= :: ARScanOpts -> ARScanOpts -> Bool
Eq)
defaultARScanOpts :: ARScanOpts
defaultARScanOpts :: ARScanOpts
defaultARScanOpts = ARScanOpts
{ arScanLimit :: Maybe Integer
arScanLimit = Maybe Integer
forall a. Maybe a
Nothing
}
newtype ARIndexValuePairsResponse = ARIndexValuePairsResponse
{ ARIndexValuePairsResponse -> [(Integer, ByteString)]
arIndexValuePairs :: [(Integer, ByteString)]
} deriving (Int -> ARIndexValuePairsResponse -> ShowS
[ARIndexValuePairsResponse] -> ShowS
ARIndexValuePairsResponse -> String
(Int -> ARIndexValuePairsResponse -> ShowS)
-> (ARIndexValuePairsResponse -> String)
-> ([ARIndexValuePairsResponse] -> ShowS)
-> Show ARIndexValuePairsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ARIndexValuePairsResponse -> ShowS
showsPrec :: Int -> ARIndexValuePairsResponse -> ShowS
$cshow :: ARIndexValuePairsResponse -> String
show :: ARIndexValuePairsResponse -> String
$cshowList :: [ARIndexValuePairsResponse] -> ShowS
showList :: [ARIndexValuePairsResponse] -> ShowS
Show, ARIndexValuePairsResponse -> ARIndexValuePairsResponse -> Bool
(ARIndexValuePairsResponse -> ARIndexValuePairsResponse -> Bool)
-> (ARIndexValuePairsResponse -> ARIndexValuePairsResponse -> Bool)
-> Eq ARIndexValuePairsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ARIndexValuePairsResponse -> ARIndexValuePairsResponse -> Bool
== :: ARIndexValuePairsResponse -> ARIndexValuePairsResponse -> Bool
$c/= :: ARIndexValuePairsResponse -> ARIndexValuePairsResponse -> Bool
/= :: ARIndexValuePairsResponse -> ARIndexValuePairsResponse -> Bool
Eq)
instance RedisResult ARIndexValuePairsResponse where
decode :: Reply -> Either Reply ARIndexValuePairsResponse
decode r :: Reply
r@(MultiBulk (Just [Reply]
replies)) =
[(Integer, ByteString)] -> ARIndexValuePairsResponse
ARIndexValuePairsResponse ([(Integer, ByteString)] -> ARIndexValuePairsResponse)
-> Either Reply [(Integer, ByteString)]
-> Either Reply ARIndexValuePairsResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Reply] -> Either Reply [(Integer, ByteString)]
forall {a} {a}.
(RedisResult a, RedisResult a) =>
[Reply] -> Either Reply [(a, a)]
decodePairs [Reply]
replies
where
decodePairs :: [Reply] -> Either Reply [(a, a)]
decodePairs [] = [(a, a)] -> Either Reply [(a, a)]
forall a b. b -> Either a b
Right []
decodePairs (MultiBulk (Just [Reply
indexReply, Reply
valueReply]):[Reply]
rest) =
(:) ((a, a) -> [(a, a)] -> [(a, a)])
-> Either Reply (a, a) -> Either Reply ([(a, a)] -> [(a, a)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (a -> a -> (a, a)) -> Either Reply a -> Either Reply (a -> (a, a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
indexReply Either Reply (a -> (a, a)) -> Either Reply a -> Either Reply (a, a)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
valueReply) Either Reply ([(a, a)] -> [(a, a)])
-> Either Reply [(a, a)] -> Either Reply [(a, a)]
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Reply] -> Either Reply [(a, a)]
decodePairs [Reply]
rest
decodePairs (Reply
indexReply:Reply
valueReply:[Reply]
rest) =
(:) ((a, a) -> [(a, a)] -> [(a, a)])
-> Either Reply (a, a) -> Either Reply ([(a, a)] -> [(a, a)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (a -> a -> (a, a)) -> Either Reply a -> Either Reply (a -> (a, a))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
indexReply Either Reply (a -> (a, a)) -> Either Reply a -> Either Reply (a, a)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
valueReply) Either Reply ([(a, a)] -> [(a, a)])
-> Either Reply [(a, a)] -> Either Reply [(a, a)]
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Reply] -> Either Reply [(a, a)]
decodePairs [Reply]
rest
decodePairs [Reply]
_ = Reply -> Either Reply [(a, a)]
forall a b. a -> Either a b
Left Reply
r
decode Reply
r = Reply -> Either Reply ARIndexValuePairsResponse
forall a b. a -> Either a b
Left Reply
r
data ARInfoResponse = ARInfoResponse
{ ARInfoResponse -> Integer
arInfoCount :: Integer
, ARInfoResponse -> Integer
arInfoLength :: Integer
, ARInfoResponse -> Integer
arInfoNextInsertIndex :: Integer
, ARInfoResponse -> Integer
arInfoSlices :: Integer
, ARInfoResponse -> Integer
arInfoDirectorySize :: Integer
, ARInfoResponse -> Integer
arInfoSuperDirEntries :: Integer
, ARInfoResponse -> Integer
arInfoSliceSize :: Integer
, ARInfoResponse -> Maybe Integer
arInfoDenseSlices :: Maybe Integer
, ARInfoResponse -> Maybe Integer
arInfoSparseSlices :: Maybe Integer
, ARInfoResponse -> Maybe Double
arInfoAvgDenseSize :: Maybe Double
, ARInfoResponse -> Maybe Double
arInfoAvgDenseFill :: Maybe Double
, ARInfoResponse -> Maybe Double
arInfoAvgSparseSize :: Maybe Double
} deriving (Int -> ARInfoResponse -> ShowS
[ARInfoResponse] -> ShowS
ARInfoResponse -> String
(Int -> ARInfoResponse -> ShowS)
-> (ARInfoResponse -> String)
-> ([ARInfoResponse] -> ShowS)
-> Show ARInfoResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ARInfoResponse -> ShowS
showsPrec :: Int -> ARInfoResponse -> ShowS
$cshow :: ARInfoResponse -> String
show :: ARInfoResponse -> String
$cshowList :: [ARInfoResponse] -> ShowS
showList :: [ARInfoResponse] -> ShowS
Show, ARInfoResponse -> ARInfoResponse -> Bool
(ARInfoResponse -> ARInfoResponse -> Bool)
-> (ARInfoResponse -> ARInfoResponse -> Bool) -> Eq ARInfoResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ARInfoResponse -> ARInfoResponse -> Bool
== :: ARInfoResponse -> ARInfoResponse -> Bool
$c/= :: ARInfoResponse -> ARInfoResponse -> Bool
/= :: ARInfoResponse -> ARInfoResponse -> Bool
Eq)
instance RedisResult ARInfoResponse where
decode :: Reply -> Either Reply ARInfoResponse
decode r :: Reply
r@(MultiBulk (Just [Reply]
replies)) = do
pairs <- [Reply] -> Either Reply [(ByteString, Reply)]
forall {a}. RedisResult a => [Reply] -> Either Reply [(a, Reply)]
parsePairs [Reply]
replies
ARInfoResponse
<$> required "count" pairs
<*> required "len" pairs
<*> required "next-insert-index" pairs
<*> required "slices" pairs
<*> required "directory-size" pairs
<*> required "super-dir-entries" pairs
<*> required "slice-size" pairs
<*> pure (optional "dense-slices" pairs)
<*> pure (optional "sparse-slices" pairs)
<*> pure (optional "avg-dense-size" pairs)
<*> pure (optional "avg-dense-fill" pairs)
<*> pure (optional "avg-sparse-size" pairs)
where
parsePairs :: [Reply] -> Either Reply [(a, Reply)]
parsePairs [] = [(a, Reply)] -> Either Reply [(a, Reply)]
forall a b. b -> Either a b
Right []
parsePairs (Reply
keyReply:Reply
valueReply:[Reply]
rest) =
(:) ((a, Reply) -> [(a, Reply)] -> [(a, Reply)])
-> Either Reply (a, Reply)
-> Either Reply ([(a, Reply)] -> [(a, Reply)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (a -> Reply -> (a, Reply))
-> Either Reply a -> Either Reply (Reply -> (a, Reply))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
keyReply Either Reply (Reply -> (a, Reply))
-> Either Reply Reply -> Either Reply (a, Reply)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Reply
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Reply
valueReply) Either Reply ([(a, Reply)] -> [(a, Reply)])
-> Either Reply [(a, Reply)] -> Either Reply [(a, Reply)]
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Reply] -> Either Reply [(a, Reply)]
parsePairs [Reply]
rest
parsePairs [Reply]
_ = Reply -> Either Reply [(a, Reply)]
forall a b. a -> Either a b
Left Reply
r
required :: RedisResult a => ByteString -> [(ByteString, Reply)] -> Either Reply a
required :: forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Either Reply a
required ByteString
key [(ByteString, Reply)]
pairs = Either Reply a
-> (Reply -> Either Reply a) -> Maybe Reply -> Either Reply a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Reply -> Either Reply a
forall a b. a -> Either a b
Left Reply
r) Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode (ByteString -> [(ByteString, Reply)] -> Maybe Reply
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
key [(ByteString, Reply)]
pairs)
optional :: RedisResult a => ByteString -> [(ByteString, Reply)] -> Maybe a
optional :: forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
key [(ByteString, Reply)]
pairs = ByteString -> [(ByteString, Reply)] -> Maybe Reply
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
key [(ByteString, Reply)]
pairs Maybe Reply -> (Reply -> Maybe a) -> Maybe a
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Reply -> Maybe a) -> (a -> Maybe a) -> Either Reply a -> Maybe a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe a -> Reply -> Maybe a
forall a b. a -> b -> a
const Maybe a
forall a. Maybe a
Nothing) a -> Maybe a
forall a. a -> Maybe a
Just (Either Reply a -> Maybe a)
-> (Reply -> Either Reply a) -> Reply -> Maybe a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode
decode Reply
r = Reply -> Either Reply ARInfoResponse
forall a b. a -> Either a b
Left Reply
r
data AROpValue
= AROpSum
| AROpMin
| AROpMax
deriving (Int -> AROpValue -> ShowS
[AROpValue] -> ShowS
AROpValue -> String
(Int -> AROpValue -> ShowS)
-> (AROpValue -> String)
-> ([AROpValue] -> ShowS)
-> Show AROpValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AROpValue -> ShowS
showsPrec :: Int -> AROpValue -> ShowS
$cshow :: AROpValue -> String
show :: AROpValue -> String
$cshowList :: [AROpValue] -> ShowS
showList :: [AROpValue] -> ShowS
Show, AROpValue -> AROpValue -> Bool
(AROpValue -> AROpValue -> Bool)
-> (AROpValue -> AROpValue -> Bool) -> Eq AROpValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AROpValue -> AROpValue -> Bool
== :: AROpValue -> AROpValue -> Bool
$c/= :: AROpValue -> AROpValue -> Bool
/= :: AROpValue -> AROpValue -> Bool
Eq)
data AROpCount
= AROpAnd
| AROpOr
| AROpXor
| AROpMatch ByteString
| AROpUsed
deriving (Int -> AROpCount -> ShowS
[AROpCount] -> ShowS
AROpCount -> String
(Int -> AROpCount -> ShowS)
-> (AROpCount -> String)
-> ([AROpCount] -> ShowS)
-> Show AROpCount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AROpCount -> ShowS
showsPrec :: Int -> AROpCount -> ShowS
$cshow :: AROpCount -> String
show :: AROpCount -> String
$cshowList :: [AROpCount] -> ShowS
showList :: [AROpCount] -> ShowS
Show, AROpCount -> AROpCount -> Bool
(AROpCount -> AROpCount -> Bool)
-> (AROpCount -> AROpCount -> Bool) -> Eq AROpCount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AROpCount -> AROpCount -> Bool
== :: AROpCount -> AROpCount -> Bool
$c/= :: AROpCount -> AROpCount -> Bool
/= :: AROpCount -> AROpCount -> Bool
Eq)
argrepPredicateArgs :: ARGrepPredicate -> [ByteString]
argrepPredicateArgs :: ARGrepPredicate -> [ByteString]
argrepPredicateArgs ARGrepPredicate
predicate =
case ARGrepPredicate
predicate of
ARGrepExact ByteString
value -> [ByteString
"EXACT", ByteString
value]
ARGrepMatch ByteString
value -> [ByteString
"MATCH", ByteString
value]
ARGrepGlob ByteString
pattern_ -> [ByteString
"GLOB", ByteString
pattern_]
ARGrepRegex ByteString
pattern_ -> [ByteString
"RE", ByteString
pattern_]
argrepOptsArgs :: ARGrepOpts -> [ByteString]
argrepOptsArgs :: ARGrepOpts -> [ByteString]
argrepOptsArgs ARGrepOpts{Bool
Maybe Integer
Maybe ARGrepCombine
arGrepCombine :: ARGrepOpts -> Maybe ARGrepCombine
arGrepLimit :: ARGrepOpts -> Maybe Integer
arGrepNoCase :: ARGrepOpts -> Bool
arGrepCombine :: Maybe ARGrepCombine
arGrepLimit :: Maybe Integer
arGrepNoCase :: Bool
..} =
[ByteString]
combineArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
limitArg [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
nocaseArg
where
combineArg :: [ByteString]
combineArg =
case Maybe ARGrepCombine
arGrepCombine of
Maybe ARGrepCombine
Nothing -> []
Just ARGrepCombine
ARGrepAnd -> [ByteString
"AND"]
Just ARGrepCombine
ARGrepOr -> [ByteString
"OR"]
limitArg :: [ByteString]
limitArg = [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
limit -> [ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
limit]) Maybe Integer
arGrepLimit
nocaseArg :: [ByteString]
nocaseArg = [ByteString
"NOCASE" | Bool
arGrepNoCase]
aropValueArg :: AROpValue -> ByteString
aropValueArg :: AROpValue -> ByteString
aropValueArg AROpValue
operation =
case AROpValue
operation of
AROpValue
AROpSum -> ByteString
"SUM"
AROpValue
AROpMin -> ByteString
"MIN"
AROpValue
AROpMax -> ByteString
"MAX"
aropCountArgs :: AROpCount -> [ByteString]
aropCountArgs :: AROpCount -> [ByteString]
aropCountArgs AROpCount
operation =
case AROpCount
operation of
AROpCount
AROpAnd -> [ByteString
"AND"]
AROpCount
AROpOr -> [ByteString
"OR"]
AROpCount
AROpXor -> [ByteString
"XOR"]
AROpMatch ByteString
value -> [ByteString
"MATCH", ByteString
value]
AROpCount
AROpUsed -> [ByteString
"USED"]
arcount
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
arcount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
arcount ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ARCOUNT", ByteString
key]
ardel
:: (RedisCtx m f)
=> ByteString
-> NonEmpty Integer
-> m (f Integer)
ardel :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty Integer -> m (f Integer)
ardel ByteString
key NonEmpty Integer
indices =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"ARDEL", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (Integer -> ByteString) -> [Integer] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (NonEmpty Integer -> [Integer]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty Integer
indices)
argetrange
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> m (f [Maybe ByteString])
argetrange :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f [Maybe ByteString])
argetrange ByteString
key Integer
start Integer
end =
[ByteString] -> m (f [Maybe ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ARGETRANGE", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
end]
argrep
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> m (f [Integer])
argrep :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> m (f [Integer])
argrep ByteString
key ByteString
start ByteString
end NonEmpty ARGrepPredicate
predicates =
ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> ARGrepOpts
-> m (f [Integer])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> ARGrepOpts
-> m (f [Integer])
argrepOpts ByteString
key ByteString
start ByteString
end NonEmpty ARGrepPredicate
predicates ARGrepOpts
defaultARGrepOpts
argrepOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> ARGrepOpts
-> m (f [Integer])
argrepOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> ARGrepOpts
-> m (f [Integer])
argrepOpts ByteString
key ByteString
start ByteString
end NonEmpty ARGrepPredicate
predicates ARGrepOpts
opts =
[ByteString] -> m (f [Integer])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [Integer]))
-> [ByteString] -> m (f [Integer])
forall a b. (a -> b) -> a -> b
$
[ByteString
"ARGREP", ByteString
key, ByteString
start, ByteString
end]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (ARGrepPredicate -> [ByteString])
-> [ARGrepPredicate] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ARGrepPredicate -> [ByteString]
argrepPredicateArgs (NonEmpty ARGrepPredicate -> [ARGrepPredicate]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ARGrepPredicate
predicates)
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ARGrepOpts -> [ByteString]
argrepOptsArgs ARGrepOpts
opts
argrepWithValues
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> m (f ARIndexValuePairsResponse)
argrepWithValues :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> m (f ARIndexValuePairsResponse)
argrepWithValues ByteString
key ByteString
start ByteString
end NonEmpty ARGrepPredicate
predicates =
ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> ARGrepOpts
-> m (f ARIndexValuePairsResponse)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> ARGrepOpts
-> m (f ARIndexValuePairsResponse)
argrepWithValuesOpts ByteString
key ByteString
start ByteString
end NonEmpty ARGrepPredicate
predicates ARGrepOpts
defaultARGrepOpts
argrepWithValuesOpts
:: (RedisCtx m f)
=> ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> ARGrepOpts
-> m (f ARIndexValuePairsResponse)
argrepWithValuesOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> ByteString
-> ByteString
-> NonEmpty ARGrepPredicate
-> ARGrepOpts
-> m (f ARIndexValuePairsResponse)
argrepWithValuesOpts ByteString
key ByteString
start ByteString
end NonEmpty ARGrepPredicate
predicates ARGrepOpts
opts =
[ByteString] -> m (f ARIndexValuePairsResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f ARIndexValuePairsResponse))
-> [ByteString] -> m (f ARIndexValuePairsResponse)
forall a b. (a -> b) -> a -> b
$
[ByteString
"ARGREP", ByteString
key, ByteString
start, ByteString
end]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (ARGrepPredicate -> [ByteString])
-> [ARGrepPredicate] -> [ByteString]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap ARGrepPredicate -> [ByteString]
argrepPredicateArgs (NonEmpty ARGrepPredicate -> [ARGrepPredicate]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ARGrepPredicate
predicates)
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"WITHVALUES"]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ ARGrepOpts -> [ByteString]
argrepOptsArgs ARGrepOpts
opts
arinfo
:: (RedisCtx m f)
=> ByteString
-> m (f ARInfoResponse)
arinfo :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ARInfoResponse)
arinfo ByteString
key = [ByteString] -> m (f ARInfoResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ARINFO", ByteString
key]
arinfoFull
:: (RedisCtx m f)
=> ByteString
-> m (f ARInfoResponse)
arinfoFull :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f ARInfoResponse)
arinfoFull ByteString
key = [ByteString] -> m (f ARInfoResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ARINFO", ByteString
key, ByteString
"FULL"]
arinsert
:: (RedisCtx m f)
=> ByteString
-> NonEmpty ByteString
-> m (f Integer)
arinsert :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty ByteString -> m (f Integer)
arinsert ByteString
key NonEmpty ByteString
values =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"ARINSERT", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
values
arlastitems
:: (RedisCtx m f)
=> ByteString
-> Integer
-> m (f [Maybe ByteString])
arlastitems :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f [Maybe ByteString])
arlastitems ByteString
key Integer
count =
ByteString
-> Integer -> ARLastItemsOpts -> m (f [Maybe ByteString])
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer -> ARLastItemsOpts -> m (f [Maybe ByteString])
arlastitemsOpts ByteString
key Integer
count ARLastItemsOpts
defaultARLastItemsOpts
arlastitemsOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> ARLastItemsOpts
-> m (f [Maybe ByteString])
arlastitemsOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer -> ARLastItemsOpts -> m (f [Maybe ByteString])
arlastitemsOpts ByteString
key Integer
count ARLastItemsOpts{Bool
arLastItemsReverse :: ARLastItemsOpts -> Bool
arLastItemsReverse :: Bool
..} =
[ByteString] -> m (f [Maybe ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [Maybe ByteString]))
-> [ByteString] -> m (f [Maybe ByteString])
forall a b. (a -> b) -> a -> b
$ [ByteString
"ARLASTITEMS", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString
"REV" | Bool
arLastItemsReverse]
arlen
:: (RedisCtx m f)
=> ByteString
-> m (f Integer)
arlen :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f Integer)
arlen ByteString
key = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ARLEN", ByteString
key]
armget
:: (RedisCtx m f)
=> ByteString
-> NonEmpty Integer
-> m (f [Maybe ByteString])
armget :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> NonEmpty Integer -> m (f [Maybe ByteString])
armget ByteString
key NonEmpty Integer
indices =
[ByteString] -> m (f [Maybe ByteString])
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f [Maybe ByteString]))
-> [ByteString] -> m (f [Maybe ByteString])
forall a b. (a -> b) -> a -> b
$ [ByteString
"ARMGET", ByteString
key] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (Integer -> ByteString) -> [Integer] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (NonEmpty Integer -> [Integer]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty Integer
indices)
arnext
:: (RedisCtx m f)
=> ByteString
-> m (f (Maybe Integer))
arnext :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> m (f (Maybe Integer))
arnext ByteString
key = [ByteString] -> m (f (Maybe Integer))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ARNEXT", ByteString
key]
aropValue
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> AROpValue
-> m (f (Maybe ByteString))
aropValue :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer -> Integer -> AROpValue -> m (f (Maybe ByteString))
aropValue ByteString
key Integer
start Integer
end AROpValue
operation =
[ByteString] -> m (f (Maybe ByteString))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"AROP", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
end, AROpValue -> ByteString
aropValueArg AROpValue
operation]
aropCount
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> AROpCount
-> m (f (Maybe Integer))
aropCount :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer -> Integer -> AROpCount -> m (f (Maybe Integer))
aropCount ByteString
key Integer
start Integer
end AROpCount
operation =
[ByteString] -> m (f (Maybe Integer))
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f (Maybe Integer)))
-> [ByteString] -> m (f (Maybe Integer))
forall a b. (a -> b) -> a -> b
$ [ByteString
"AROP", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
end] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ AROpCount -> [ByteString]
aropCountArgs AROpCount
operation
arring
:: (RedisCtx m f)
=> ByteString
-> Integer
-> NonEmpty ByteString
-> m (f Integer)
arring :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> NonEmpty ByteString -> m (f Integer)
arring ByteString
key Integer
size NonEmpty ByteString
values =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"ARRING", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
size] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
values
arscan
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> m (f ARIndexValuePairsResponse)
arscan :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f ARIndexValuePairsResponse)
arscan ByteString
key Integer
start Integer
end =
ByteString
-> Integer
-> Integer
-> ARScanOpts
-> m (f ARIndexValuePairsResponse)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer
-> Integer
-> ARScanOpts
-> m (f ARIndexValuePairsResponse)
arscanOpts ByteString
key Integer
start Integer
end ARScanOpts
defaultARScanOpts
arscanOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> ARScanOpts
-> m (f ARIndexValuePairsResponse)
arscanOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString
-> Integer
-> Integer
-> ARScanOpts
-> m (f ARIndexValuePairsResponse)
arscanOpts ByteString
key Integer
start Integer
end ARScanOpts{Maybe Integer
arScanLimit :: ARScanOpts -> Maybe Integer
arScanLimit :: Maybe Integer
..} =
[ByteString] -> m (f ARIndexValuePairsResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f ARIndexValuePairsResponse))
-> [ByteString] -> m (f ARIndexValuePairsResponse)
forall a b. (a -> b) -> a -> b
$
[ByteString
"ARSCAN", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
end]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
limit -> [ByteString
"LIMIT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
limit]) Maybe Integer
arScanLimit
arseek
:: (RedisCtx m f)
=> ByteString
-> Integer
-> m (f Bool)
arseek :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> m (f Bool)
arseek ByteString
key Integer
index = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"ARSEEK", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
index]
arset
:: (RedisCtx m f)
=> ByteString
-> Integer
-> NonEmpty ByteString
-> m (f Integer)
arset :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> NonEmpty ByteString -> m (f Integer)
arset ByteString
key Integer
index NonEmpty ByteString
values =
[ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Integer)) -> [ByteString] -> m (f Integer)
forall a b. (a -> b) -> a -> b
$ [ByteString
"ARSET", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
index] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ NonEmpty ByteString -> [ByteString]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty ByteString
values
data HotkeysMetric
= HotkeysMetricCPU
| HotkeysMetricNET
deriving (Int -> HotkeysMetric -> ShowS
[HotkeysMetric] -> ShowS
HotkeysMetric -> String
(Int -> HotkeysMetric -> ShowS)
-> (HotkeysMetric -> String)
-> ([HotkeysMetric] -> ShowS)
-> Show HotkeysMetric
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HotkeysMetric -> ShowS
showsPrec :: Int -> HotkeysMetric -> ShowS
$cshow :: HotkeysMetric -> String
show :: HotkeysMetric -> String
$cshowList :: [HotkeysMetric] -> ShowS
showList :: [HotkeysMetric] -> ShowS
Show, HotkeysMetric -> HotkeysMetric -> Bool
(HotkeysMetric -> HotkeysMetric -> Bool)
-> (HotkeysMetric -> HotkeysMetric -> Bool) -> Eq HotkeysMetric
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HotkeysMetric -> HotkeysMetric -> Bool
== :: HotkeysMetric -> HotkeysMetric -> Bool
$c/= :: HotkeysMetric -> HotkeysMetric -> Bool
/= :: HotkeysMetric -> HotkeysMetric -> Bool
Eq)
instance RedisArg HotkeysMetric where
encode :: HotkeysMetric -> ByteString
encode HotkeysMetric
HotkeysMetricCPU = ByteString
"CPU"
encode HotkeysMetric
HotkeysMetricNET = ByteString
"NET"
data HotkeysStartOpts = HotkeysStartOpts
{ HotkeysStartOpts -> Maybe Integer
hotkeysStartTopKCount :: Maybe Integer
, HotkeysStartOpts -> Maybe Integer
hotkeysStartDurationSeconds :: Maybe Integer
, HotkeysStartOpts -> Maybe Integer
hotkeysStartSampleRatio :: Maybe Integer
, HotkeysStartOpts -> Maybe (NonEmpty Integer)
hotkeysStartSlots :: Maybe (NonEmpty Integer)
} deriving (Int -> HotkeysStartOpts -> ShowS
[HotkeysStartOpts] -> ShowS
HotkeysStartOpts -> String
(Int -> HotkeysStartOpts -> ShowS)
-> (HotkeysStartOpts -> String)
-> ([HotkeysStartOpts] -> ShowS)
-> Show HotkeysStartOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HotkeysStartOpts -> ShowS
showsPrec :: Int -> HotkeysStartOpts -> ShowS
$cshow :: HotkeysStartOpts -> String
show :: HotkeysStartOpts -> String
$cshowList :: [HotkeysStartOpts] -> ShowS
showList :: [HotkeysStartOpts] -> ShowS
Show, HotkeysStartOpts -> HotkeysStartOpts -> Bool
(HotkeysStartOpts -> HotkeysStartOpts -> Bool)
-> (HotkeysStartOpts -> HotkeysStartOpts -> Bool)
-> Eq HotkeysStartOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HotkeysStartOpts -> HotkeysStartOpts -> Bool
== :: HotkeysStartOpts -> HotkeysStartOpts -> Bool
$c/= :: HotkeysStartOpts -> HotkeysStartOpts -> Bool
/= :: HotkeysStartOpts -> HotkeysStartOpts -> Bool
Eq)
defaultHotkeysStartOpts :: HotkeysStartOpts
defaultHotkeysStartOpts :: HotkeysStartOpts
defaultHotkeysStartOpts = HotkeysStartOpts
{ hotkeysStartTopKCount :: Maybe Integer
hotkeysStartTopKCount = Maybe Integer
forall a. Maybe a
Nothing
, hotkeysStartDurationSeconds :: Maybe Integer
hotkeysStartDurationSeconds = Maybe Integer
forall a. Maybe a
Nothing
, hotkeysStartSampleRatio :: Maybe Integer
hotkeysStartSampleRatio = Maybe Integer
forall a. Maybe a
Nothing
, hotkeysStartSlots :: Maybe (NonEmpty Integer)
hotkeysStartSlots = Maybe (NonEmpty Integer)
forall a. Maybe a
Nothing
}
data HotkeysSlotRange = HotkeysSlotRange
{ HotkeysSlotRange -> Integer
hotkeysSlotRangeStart :: Integer
, HotkeysSlotRange -> Integer
hotkeysSlotRangeEnd :: Integer
} deriving (Int -> HotkeysSlotRange -> ShowS
[HotkeysSlotRange] -> ShowS
HotkeysSlotRange -> String
(Int -> HotkeysSlotRange -> ShowS)
-> (HotkeysSlotRange -> String)
-> ([HotkeysSlotRange] -> ShowS)
-> Show HotkeysSlotRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HotkeysSlotRange -> ShowS
showsPrec :: Int -> HotkeysSlotRange -> ShowS
$cshow :: HotkeysSlotRange -> String
show :: HotkeysSlotRange -> String
$cshowList :: [HotkeysSlotRange] -> ShowS
showList :: [HotkeysSlotRange] -> ShowS
Show, HotkeysSlotRange -> HotkeysSlotRange -> Bool
(HotkeysSlotRange -> HotkeysSlotRange -> Bool)
-> (HotkeysSlotRange -> HotkeysSlotRange -> Bool)
-> Eq HotkeysSlotRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HotkeysSlotRange -> HotkeysSlotRange -> Bool
== :: HotkeysSlotRange -> HotkeysSlotRange -> Bool
$c/= :: HotkeysSlotRange -> HotkeysSlotRange -> Bool
/= :: HotkeysSlotRange -> HotkeysSlotRange -> Bool
Eq)
instance RedisResult HotkeysSlotRange where
decode :: Reply -> Either Reply HotkeysSlotRange
decode (MultiBulk (Just [Integer Integer
slot])) =
HotkeysSlotRange -> Either Reply HotkeysSlotRange
forall a b. b -> Either a b
Right HotkeysSlotRange
{ hotkeysSlotRangeStart :: Integer
hotkeysSlotRangeStart = Integer
slot
, hotkeysSlotRangeEnd :: Integer
hotkeysSlotRangeEnd = Integer
slot
}
decode (MultiBulk (Just [Integer Integer
start, Integer Integer
end])) =
HotkeysSlotRange -> Either Reply HotkeysSlotRange
forall a b. b -> Either a b
Right HotkeysSlotRange
{ hotkeysSlotRangeStart :: Integer
hotkeysSlotRangeStart = Integer
start
, hotkeysSlotRangeEnd :: Integer
hotkeysSlotRangeEnd = Integer
end
}
decode Reply
r = Reply -> Either Reply HotkeysSlotRange
forall a b. a -> Either a b
Left Reply
r
data HotkeysGetResponse = HotkeysGetResponse
{ HotkeysGetResponse -> Bool
hotkeysGetTrackingActive :: Bool
, HotkeysGetResponse -> Integer
hotkeysGetSampleRatio :: Integer
, HotkeysGetResponse -> [HotkeysSlotRange]
hotkeysGetSelectedSlots :: [HotkeysSlotRange]
, HotkeysGetResponse -> Integer
hotkeysGetAllCommandsAllSlotsUs :: Integer
, HotkeysGetResponse -> Integer
hotkeysGetNetBytesAllCommandsAllSlots :: Integer
, HotkeysGetResponse -> Integer
hotkeysGetCollectionStartTimeUnixMs :: Integer
, HotkeysGetResponse -> Integer
hotkeysGetCollectionDurationMs :: Integer
, HotkeysGetResponse -> Maybe Integer
hotkeysGetTotalCpuTimeUserMs :: Maybe Integer
, HotkeysGetResponse -> Maybe Integer
hotkeysGetTotalCpuTimeSysMs :: Maybe Integer
, HotkeysGetResponse -> Maybe Integer
hotkeysGetTotalNetBytes :: Maybe Integer
, HotkeysGetResponse -> Maybe [(ByteString, Integer)]
hotkeysGetByCpuTimeUs :: Maybe [(ByteString, Integer)]
, HotkeysGetResponse -> Maybe [(ByteString, Integer)]
hotkeysGetByNetBytes :: Maybe [(ByteString, Integer)]
, HotkeysGetResponse -> Maybe Integer
hotkeysGetSampledCommandsSelectedSlotsUs :: Maybe Integer
, HotkeysGetResponse -> Maybe Integer
hotkeysGetAllCommandsSelectedSlotsUs :: Maybe Integer
, HotkeysGetResponse -> Maybe Integer
hotkeysGetNetBytesSampledCommandsSelectedSlots :: Maybe Integer
, HotkeysGetResponse -> Maybe Integer
hotkeysGetNetBytesAllCommandsSelectedSlots :: Maybe Integer
} deriving (Int -> HotkeysGetResponse -> ShowS
[HotkeysGetResponse] -> ShowS
HotkeysGetResponse -> String
(Int -> HotkeysGetResponse -> ShowS)
-> (HotkeysGetResponse -> String)
-> ([HotkeysGetResponse] -> ShowS)
-> Show HotkeysGetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HotkeysGetResponse -> ShowS
showsPrec :: Int -> HotkeysGetResponse -> ShowS
$cshow :: HotkeysGetResponse -> String
show :: HotkeysGetResponse -> String
$cshowList :: [HotkeysGetResponse] -> ShowS
showList :: [HotkeysGetResponse] -> ShowS
Show, HotkeysGetResponse -> HotkeysGetResponse -> Bool
(HotkeysGetResponse -> HotkeysGetResponse -> Bool)
-> (HotkeysGetResponse -> HotkeysGetResponse -> Bool)
-> Eq HotkeysGetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HotkeysGetResponse -> HotkeysGetResponse -> Bool
== :: HotkeysGetResponse -> HotkeysGetResponse -> Bool
$c/= :: HotkeysGetResponse -> HotkeysGetResponse -> Bool
/= :: HotkeysGetResponse -> HotkeysGetResponse -> Bool
Eq)
instance RedisResult HotkeysGetResponse where
decode :: Reply -> Either Reply HotkeysGetResponse
decode (MultiBulk (Just [Reply
payload])) = Reply -> Either Reply HotkeysGetResponse
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
payload
decode r :: Reply
r@(MultiBulk (Just [Reply]
replies)) = do
pairs <- [Reply] -> Either Reply [(ByteString, Reply)]
forall {a}. RedisResult a => [Reply] -> Either Reply [(a, Reply)]
parsePairs [Reply]
replies
hotkeysGetTrackingActive <- require "tracking-active" pairs
hotkeysGetSampleRatio <- require "sample-ratio" pairs
hotkeysGetSelectedSlots <- require "selected-slots" pairs
hotkeysGetAllCommandsAllSlotsUs <- require "all-commands-all-slots-us" pairs
hotkeysGetNetBytesAllCommandsAllSlots <- require "net-bytes-all-commands-all-slots" pairs
hotkeysGetCollectionStartTimeUnixMs <- require "collection-start-time-unix-ms" pairs
hotkeysGetCollectionDurationMs <- require "collection-duration-ms" pairs
let hotkeysGetTotalCpuTimeUserMs = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
"total-cpu-time-user-ms" [(ByteString, Reply)]
pairs
hotkeysGetTotalCpuTimeSysMs = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
"total-cpu-time-sys-ms" [(ByteString, Reply)]
pairs
hotkeysGetTotalNetBytes = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
"total-net-bytes" [(ByteString, Reply)]
pairs
hotkeysGetByCpuTimeUs = ByteString
-> [(ByteString, Reply)] -> Maybe [(ByteString, Integer)]
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
"by-cpu-time-us" [(ByteString, Reply)]
pairs
hotkeysGetByNetBytes = ByteString
-> [(ByteString, Reply)] -> Maybe [(ByteString, Integer)]
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
"by-net-bytes" [(ByteString, Reply)]
pairs
hotkeysGetSampledCommandsSelectedSlotsUs = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
"sampled-commands-selected-slots-us" [(ByteString, Reply)]
pairs
hotkeysGetAllCommandsSelectedSlotsUs = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
"all-commands-selected-slots-us" [(ByteString, Reply)]
pairs
hotkeysGetNetBytesSampledCommandsSelectedSlots = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
"net-bytes-sampled-commands-selected-slots" [(ByteString, Reply)]
pairs
hotkeysGetNetBytesAllCommandsSelectedSlots = ByteString -> [(ByteString, Reply)] -> Maybe Integer
forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
"net-bytes-all-commands-selected-slots" [(ByteString, Reply)]
pairs
pure HotkeysGetResponse{..}
where
parsePairs :: [Reply] -> Either Reply [(a, Reply)]
parsePairs [] = [(a, Reply)] -> Either Reply [(a, Reply)]
forall a b. b -> Either a b
Right []
parsePairs (Reply
keyReply:Reply
valueReply:[Reply]
rest) =
(:) ((a, Reply) -> [(a, Reply)] -> [(a, Reply)])
-> Either Reply (a, Reply)
-> Either Reply ([(a, Reply)] -> [(a, Reply)])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((,) (a -> Reply -> (a, Reply))
-> Either Reply a -> Either Reply (Reply -> (a, Reply))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode Reply
keyReply Either Reply (Reply -> (a, Reply))
-> Either Reply Reply -> Either Reply (a, Reply)
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Reply -> Either Reply Reply
forall a. a -> Either Reply a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Reply
valueReply) Either Reply ([(a, Reply)] -> [(a, Reply)])
-> Either Reply [(a, Reply)] -> Either Reply [(a, Reply)]
forall a b.
Either Reply (a -> b) -> Either Reply a -> Either Reply b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> [Reply] -> Either Reply [(a, Reply)]
parsePairs [Reply]
rest
parsePairs [Reply]
_ = Reply -> Either Reply [(a, Reply)]
forall a b. a -> Either a b
Left Reply
r
require :: RedisResult a => ByteString -> [(ByteString, Reply)] -> Either Reply a
require :: forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Either Reply a
require ByteString
key [(ByteString, Reply)]
pairs =
Either Reply a
-> (Reply -> Either Reply a) -> Maybe Reply -> Either Reply a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Reply -> Either Reply a
forall a b. a -> Either a b
Left Reply
r) Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode (ByteString -> [(ByteString, Reply)] -> Maybe Reply
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
key [(ByteString, Reply)]
pairs)
optional :: RedisResult a => ByteString -> [(ByteString, Reply)] -> Maybe a
optional :: forall a.
RedisResult a =>
ByteString -> [(ByteString, Reply)] -> Maybe a
optional ByteString
key [(ByteString, Reply)]
pairs = ByteString -> [(ByteString, Reply)] -> Maybe Reply
forall a b. Eq a => a -> [(a, b)] -> Maybe b
lookup ByteString
key [(ByteString, Reply)]
pairs Maybe Reply -> (Reply -> Maybe a) -> Maybe a
forall a b. Maybe a -> (a -> Maybe b) -> Maybe b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Reply -> Maybe a) -> (a -> Maybe a) -> Either Reply a -> Maybe a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (Maybe a -> Reply -> Maybe a
forall a b. a -> b -> a
const Maybe a
forall a. Maybe a
Nothing) a -> Maybe a
forall a. a -> Maybe a
Just (Either Reply a -> Maybe a)
-> (Reply -> Either Reply a) -> Reply -> Maybe a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Reply -> Either Reply a
forall a. RedisResult a => Reply -> Either Reply a
decode
decode Reply
r = Reply -> Either Reply HotkeysGetResponse
forall a b. a -> Either a b
Left Reply
r
hotkeysStart
:: (RedisCtx m f)
=> NonEmpty HotkeysMetric
-> m (f Status)
hotkeysStart :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty HotkeysMetric -> m (f Status)
hotkeysStart NonEmpty HotkeysMetric
metrics = NonEmpty HotkeysMetric -> HotkeysStartOpts -> m (f Status)
forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty HotkeysMetric -> HotkeysStartOpts -> m (f Status)
hotkeysStartOpts NonEmpty HotkeysMetric
metrics HotkeysStartOpts
defaultHotkeysStartOpts
hotkeysStartOpts
:: (RedisCtx m f)
=> NonEmpty HotkeysMetric
-> HotkeysStartOpts
-> m (f Status)
hotkeysStartOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
NonEmpty HotkeysMetric -> HotkeysStartOpts -> m (f Status)
hotkeysStartOpts NonEmpty HotkeysMetric
metrics HotkeysStartOpts{Maybe Integer
Maybe (NonEmpty Integer)
hotkeysStartTopKCount :: HotkeysStartOpts -> Maybe Integer
hotkeysStartDurationSeconds :: HotkeysStartOpts -> Maybe Integer
hotkeysStartSampleRatio :: HotkeysStartOpts -> Maybe Integer
hotkeysStartSlots :: HotkeysStartOpts -> Maybe (NonEmpty Integer)
hotkeysStartTopKCount :: Maybe Integer
hotkeysStartDurationSeconds :: Maybe Integer
hotkeysStartSampleRatio :: Maybe Integer
hotkeysStartSlots :: Maybe (NonEmpty Integer)
..} =
[ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest ([ByteString] -> m (f Status)) -> [ByteString] -> m (f Status)
forall a b. (a -> b) -> a -> b
$
[ByteString
"HOTKEYS", ByteString
"START", ByteString
"METRICS", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty HotkeysMetric -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty HotkeysMetric
metrics)]
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (HotkeysMetric -> ByteString) -> [HotkeysMetric] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map HotkeysMetric -> ByteString
forall a. RedisArg a => a -> ByteString
encode (NonEmpty HotkeysMetric -> [HotkeysMetric]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty HotkeysMetric
metrics)
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
count -> [ByteString
"COUNT", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
count]) Maybe Integer
hotkeysStartTopKCount
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
duration -> [ByteString
"DURATION", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
duration]) Maybe Integer
hotkeysStartDurationSeconds
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (Integer -> [ByteString]) -> Maybe Integer -> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Integer
ratio -> [ByteString
"SAMPLE", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
ratio]) Maybe Integer
hotkeysStartSampleRatio
[ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ByteString]
-> (NonEmpty Integer -> [ByteString])
-> Maybe (NonEmpty Integer)
-> [ByteString]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] NonEmpty Integer -> [ByteString]
forall {a}. RedisArg a => NonEmpty a -> [ByteString]
slotsArgs Maybe (NonEmpty Integer)
hotkeysStartSlots
where
slotsArgs :: NonEmpty a -> [ByteString]
slotsArgs NonEmpty a
slots = [ByteString
"SLOTS", Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode (Int -> Integer
forall a. Integral a => a -> Integer
toInteger (Int -> Integer) -> Int -> Integer
forall a b. (a -> b) -> a -> b
$ NonEmpty a -> Int
forall a. NonEmpty a -> Int
NE.length NonEmpty a
slots)] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ (a -> ByteString) -> [a] -> [ByteString]
forall a b. (a -> b) -> [a] -> [b]
map a -> ByteString
forall a. RedisArg a => a -> ByteString
encode (NonEmpty a -> [a]
forall a. NonEmpty a -> [a]
NE.toList NonEmpty a
slots)
hotkeysGet
:: (RedisCtx m f)
=> m (f HotkeysGetResponse)
hotkeysGet :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
m (f HotkeysGetResponse)
hotkeysGet = [ByteString] -> m (f HotkeysGetResponse)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"HOTKEYS", ByteString
"GET"]
hotkeysStop
:: (RedisCtx m f)
=> m (f Status)
hotkeysStop :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
hotkeysStop = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"HOTKEYS", ByteString
"STOP"]
hotkeysReset
:: (RedisCtx m f)
=> m (f Status)
hotkeysReset :: forall (m :: * -> *) (f :: * -> *). RedisCtx m f => m (f Status)
hotkeysReset = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"HOTKEYS", ByteString
"RESET"]
data ExpireOpts
= ExpireOptsTime Condition
| ExpireOptsValue SizeCondition
instance RedisArg ExpireOpts where
encode :: ExpireOpts -> ByteString
encode (ExpireOptsTime Condition
c) = Condition -> ByteString
forall a. RedisArg a => a -> ByteString
encode Condition
c
encode (ExpireOptsValue SizeCondition
c) = SizeCondition -> ByteString
forall a. RedisArg a => a -> ByteString
encode SizeCondition
c
pexpireatOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> ExpireOpts
-> m (f Bool)
pexpireatOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ExpireOpts -> m (f Bool)
pexpireatOpts ByteString
key Integer
millisecondsTimestamp ExpireOpts
opts =
[ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"PEXPIREAT", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
millisecondsTimestamp, ExpireOpts -> ByteString
forall a. RedisArg a => a -> ByteString
encode ExpireOpts
opts]
expireOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> ExpireOpts
-> m (f Bool)
expireOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ExpireOpts -> m (f Bool)
expireOpts ByteString
key Integer
seconds ExpireOpts
opts = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"EXPIRE", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
seconds, ExpireOpts -> ByteString
forall a. RedisArg a => a -> ByteString
encode ExpireOpts
opts]
expireatOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> ExpireOpts
-> m (f Bool)
expireatOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> ExpireOpts -> m (f Bool)
expireatOpts ByteString
key Integer
timestamp ExpireOpts
opts = [ByteString] -> m (f Bool)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"EXPIREAT", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
timestamp, ExpireOpts -> ByteString
forall a. RedisArg a => a -> ByteString
encode ExpireOpts
opts]
data FlushOpts
= FlushOptsSync
| FlushOptsAsync
instance RedisArg FlushOpts where
encode :: FlushOpts -> ByteString
encode FlushOpts
FlushOptsSync = ByteString
"SYNC"
encode FlushOpts
FlushOptsAsync = ByteString
"ASYNC"
flushdbOpts
:: (RedisCtx m f)
=> FlushOpts
-> m (f Status)
flushdbOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
FlushOpts -> m (f Status)
flushdbOpts FlushOpts
opts = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FLUSHDB", FlushOpts -> ByteString
forall a. RedisArg a => a -> ByteString
encode FlushOpts
opts]
flushallOpts
:: (RedisCtx m f)
=> FlushOpts
-> m (f Status)
flushallOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
FlushOpts -> m (f Status)
flushallOpts FlushOpts
opts = [ByteString] -> m (f Status)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"FLUSHALL", FlushOpts -> ByteString
forall a. RedisArg a => a -> ByteString
encode FlushOpts
opts]
data BitposType = Byte | Bit
instance RedisArg BitposType where
encode :: BitposType -> ByteString
encode BitposType
Byte = ByteString
"BYTE"
encode BitposType
Bit = ByteString
"BIT"
data BitposOpts
= BitposOptsStart Integer
| BitposOptsStartEnd Integer Integer (Maybe BitposType)
bitposOpts
:: (RedisCtx m f)
=> ByteString
-> Integer
-> BitposOpts
-> m (f Integer)
bitposOpts :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> BitposOpts -> m (f Integer)
bitposOpts ByteString
key_ Integer
bit BitposOpts
opts = [ByteString] -> m (f Integer)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest (ByteString
"BITPOS"ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: ByteString
key_ByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
:Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
bitByteString -> [ByteString] -> [ByteString]
forall a. a -> [a] -> [a]
: [ByteString]
rest) where
rest :: [ByteString]
rest = case BitposOpts
opts of
BitposOptsStart Integer
s -> [Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
s]
BitposOptsStartEnd Integer
start Integer
end Maybe BitposType
bits ->
[Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
end] [ByteString] -> [ByteString] -> [ByteString]
forall a. [a] -> [a] -> [a]
++ [ BitposType -> ByteString
forall a. RedisArg a => a -> ByteString
encode BitposType
bits_ | Just BitposType
bits_ <- Maybe BitposType -> [Maybe BitposType]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe BitposType
bits]
substr
:: (RedisCtx m f)
=> ByteString
-> Integer
-> Integer
-> m (f ByteString)
substr :: forall (m :: * -> *) (f :: * -> *).
RedisCtx m f =>
ByteString -> Integer -> Integer -> m (f ByteString)
substr ByteString
key Integer
start Integer
end = [ByteString] -> m (f ByteString)
forall (m :: * -> *) (f :: * -> *) a.
(RedisCtx m f, RedisResult a) =>
[ByteString] -> m (f a)
sendRequest [ByteString
"SUBSTR", ByteString
key, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
start, Integer -> ByteString
forall a. RedisArg a => a -> ByteString
encode Integer
end]