module Database.Redis.List ( listRightPush , listRightPushB , listLeftPush , listLeftPushB , listLength , listLengthB , listRange , listRangeB , listIndex , listIndexB ) where -- import Data.ByteString (ByteString) import System.IO import Database.Redis.Internal ------------------------------------------------------------------------------ -- | RPUSH listRightPush :: Handle -> String -- ^ key -> String -- ^ value -> IO (Maybe RedisReply) listRightPush h key value = request h $ map toUTF8 ["RPUSH", key, value] -- | RPUSH for ByteString input listRightPushB :: Handle -> ByteString -- ^ key -> ByteString -- ^ value -> IO (Maybe RedisReply) listRightPushB h key value = request h [toUTF8 "RPUSH", key, value] ------------------------------------------------------------------------------ -- LPUSH listLeftPush :: Handle -> String -- ^ key -> String -- ^ value -> IO (Maybe RedisReply) listLeftPush h key value = request h $ map toUTF8 ["LPUSH", key, value] -- | LPUSH for ByteString input listLeftPushB :: Handle -> ByteString -- ^ key -> ByteString -- ^ value -> IO (Maybe RedisReply) listLeftPushB h key value = request h [toUTF8 "LPUSH", key, value] ------------------------------------------------------------------------------ -- | LLEN listLength :: Handle -> String -- ^ key -> IO (Maybe RedisReply) listLength h key = request h $ map toUTF8 ["LLEN", key] -- | LLEN for ByteString input listLengthB :: Handle -> ByteString -- ^ key -> IO (Maybe RedisReply) listLengthB h key = request h [toUTF8 "LLEN", key] ------------------------------------------------------------------------------ -- | LRANGE listRange :: Handle -> String -- ^ key -> Int -- ^ start -> Int -- ^ end -> IO (Maybe RedisReply) listRange h key start end = request h $ map toUTF8 ["LRANGE", key, show start, show end] -- | LRANGE for ByteString input listRangeB :: Handle -> ByteString -- ^ key -> Int -- ^ start -> Int -- ^ end -> IO (Maybe RedisReply) listRangeB h key start end = request h [toUTF8 "LRANGE", key, toUTF8 $ show start, toUTF8 $ show end] ------------------------------------------------------------------------------ -- LTRIM ------------------------------------------------------------------------------ -- LINDEX listIndex :: Handle -> String -- ^ key -> Int -- ^ index -> IO (Maybe RedisReply) listIndex h key index = request h $ map toUTF8 ["LINDEX", key, show index] -- LINDEX for ByteString input listIndexB :: Handle -> ByteString -- ^ key -> Int -- ^ index -> IO (Maybe RedisReply) listIndexB h key index = request h [toUTF8 "LINDEX", key, toUTF8 $ show index] -- LSET -- LREM -- LPOP -- RPOP -- BLPOP -- BRPOP -- RPOPLPUSH