-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A driver for Redis key-value database -- -- Redis is an advanced key-value store. It is similar to memcached but -- the dataset is not volatile. Values can be strings, exactly like in -- memcached, but also lists, sets, and ordered sets. -- -- This library is a Haskell driver for Redis. @package redis @version 0.1 -- | Main Redis API and protocol implementation module Database.Redis.Redis -- | Redis connection descriptor data Redis Redis :: (String, String) -> Handle -> Redis -- | hostname and port pair server :: Redis -> (String, String) -- | real network connection handle :: Redis -> Handle -- | Redis reply variants data Reply -- | Timeout. Currently unused RTimeout :: Reply -- | "Ok" reply ROk :: Reply -- | Reply for the ping command RPong :: Reply -- | Used inside multi-exec block RQueued :: Reply -- | Some kind of server-side error RError :: String -> Reply -- | Simple oneline reply RInline :: String -> Reply -- | Integer reply RInt :: Int -> Reply -- | Multiline reply RBulk :: (Maybe String) -> Reply -- | Complex reply. It may consists of various type of replys RMulti :: (Maybe [Reply]) -> Reply -- | Interval representation data Interval a -- | closed interval [a, b] Closed :: a -> a -> Interval a -- | open interval (a, b) Open :: a -> a -> Interval a -- | left-open interval (a, b] LeftOpen :: a -> a -> Interval a -- | right-open interval [a, b) RightOpen :: a -> a -> Interval a -- | Class for conversion value to Interval -- -- Definied instances is: -- -- class IsInterval i a | i -> a toInterval :: (IsInterval i a) => i -> Interval a -- | Options data type for the sort command data SortOptions SortOptions :: Bool -> (Int, Int) -> Bool -> String -> [String] -> String -> SortOptions -- | sort with descending order desc :: SortOptions -> Bool -- | return (from, to) elements limit :: SortOptions -> (Int, Int) -- | sort alphabetically alpha :: SortOptions -> Bool -- | sort by value from this key sort_by :: SortOptions -> String -- | return this keys values get_obj :: SortOptions -> [String] -- | store result to this key store :: SortOptions -> String -- | Default options for the sort command sortDefaults :: SortOptions -- | Unwraps RInline reply. -- -- Throws an exception when called with something different from RInline fromRInline :: (Monad m) => Reply -> m String -- | Unwraps RBulk reply. -- -- Throws an exception when called with something different from RBulk fromRBulk :: (Monad m) => Reply -> m (Maybe String) -- | Unwraps RMulti reply -- -- Throws an exception when called with something different from RMulti fromRMulti :: (Monad m) => Reply -> m (Maybe [Reply]) -- | Unwraps RMulti reply filled with RBulk -- -- Throws an exception when called with something different from RMulti fromRMultiBulk :: (Monad m) => Reply -> m (Maybe [Maybe String]) -- | Unwraps RInt reply -- -- Throws an exception when called with something different from RInt fromRInt :: (Monad m) => Reply -> m Int -- | Unwraps ROk reply -- -- Throws an exception when called with something different from ROk fromROk :: (Monad m) => Reply -> m () -- | Unwraps every non-error reply -- -- Throws an exception when called with something different from RMulti noError :: (Monad m) => Reply -> m () -- | a (0, -1) range - takes all element from a list in lrange, zrange and -- so on takeAll :: (Int, Int) -- | just a localhost localhost :: String -- | default Redis port defaultPort :: String -- | Conects to Redis server and returns connection descriptor connect :: String -> String -> IO Redis -- | Close connection disconnect :: Redis -> IO () -- | Returns True when connection handler is opened isConnected :: Redis -> IO Bool -- | ping - pong -- -- RPong returned if no errors happends ping :: Redis -> IO Reply -- | Password authentication -- -- ROk returned auth :: Redis -> String -> IO Reply -- | Quit and close connection quit :: Redis -> IO () -- | Stop all the clients, save the DB, then quit the server shutdown :: Redis -> IO Reply -- | Begin the multi-exec block -- -- ROk returned multi :: Redis -> IO Reply -- | Execute queued commands -- -- RMulti returned - replys for all executed commands exec :: Redis -> IO Reply -- | Run commands within multi-exec block -- -- RMulti returned - replys for all executed commands run_multi :: Redis -> [IO Reply] -> IO Reply -- | Test if the key exists -- -- (RInt 1) returned if the key exists and (RInt 0) otherwise exists :: Redis -> String -> IO Reply -- | Remove the key -- -- (RInt 0) returned if no keys were removed or (RInt n) with removed -- keys count del :: Redis -> String -> IO Reply -- | Return the type of the value stored at key in form of a string -- -- RInline with one of none, string, list, -- set, zset returned getType :: Redis -> String -> IO Reply -- | Returns all the keys matching the glob-style pattern as space -- separated strings -- -- RBulk returned keys :: Redis -> String -> IO Reply -- | Return random key name -- -- RInline returned randomKey :: Redis -> IO Reply -- | Rename the key. If key with that name exists it'll be overwritten. -- -- ROk returned rename :: Redis -> String -> String -> IO Reply -- | Rename the key if no keys with destination name exists. -- -- (RInt 1) returned if key was renamed and (RInt 0) otherwise renameNx :: Redis -> String -> String -> IO Reply -- | Get the number of keys in the currently selected database -- -- RInt returned dbsize :: Redis -> IO Reply -- | Set an expiration timeout in seconds on the specified key. -- -- For more information see -- http://code.google.com/p/redis/wiki/ExpireCommand -- -- (RInt 1) returned if timeout was set and (RInt 0) otherwise expire :: Redis -> String -> Int -> IO Reply -- | Set an expiration time in form of UNIX timestamp on the specified key -- -- For more information see -- http://code.google.com/p/redis/wiki/ExpireCommand -- -- (RInt 1) returned if timeout was set and (RInt 0) otherwise expireAt :: Redis -> String -> Int -> IO Reply -- | Return the remining time to live of the key or -1 if key has no -- associated timeout -- -- RInt returned ttl :: Redis -> String -> IO Reply -- | Select the DB with the specified zero-based numeric index -- -- ROk returned select :: Redis -> Int -> IO Reply -- | Move the specified key from the currently selected DB to the specified -- destination DB. If such a key is already exists in the target DB no -- data modification performed. -- -- (RInt 1) returned if the key was moved and (RInt 0) otherwise move :: Redis -> String -> Int -> IO Reply -- | Delete all the keys of the currently selected DB -- -- ROk returned flushDb :: Redis -> IO Reply -- | Delete all the keys of all the existing databases -- -- ROk returned flushAll :: Redis -> IO Reply -- | Returns different information and statistics about the server -- -- for more information see -- http://code.google.com/p/redis/wiki/InfoCommand -- -- RBulk returned info :: Redis -> IO Reply -- | Set the string value as value of the key -- -- ROk returned set :: Redis -> String -> String -> IO Reply -- | Set the key value if key does not exists -- -- (RInt 1) returned if key was set and (RInt 0) otherwise setNx :: Redis -> String -> String -> IO Reply -- | Atomically set multiple keys -- -- ROk returned mSet :: Redis -> [(String, String)] -> IO Reply -- | Atomically set multiple keys if none of them exists. -- -- (RInt 1) returned if all keys was set and (RInt 0) otherwise mSetNx :: Redis -> [(String, String)] -> IO Reply -- | Get the value of the specified key. -- -- RBulk returned get :: Redis -> String -> IO Reply -- | Atomically set this value and return the old value -- -- RBulk returned getSet :: Redis -> String -> String -> IO Reply -- | Get the values of all specified keys -- -- RMulti filled with RBulk replys returned mGet :: Redis -> [String] -> IO Reply -- | Increment the key value by one -- -- RInt returned with new key value incr :: Redis -> String -> IO Reply -- | Increment the key value by N -- -- RInt returned with new key value incrBy :: Redis -> String -> Int -> IO Reply -- | Decrement the key value by one -- -- RInt returned with new key value decr :: Redis -> String -> IO Reply -- | Decrement the key value by N -- -- RInt returned with new key value decrBy :: Redis -> String -> Int -> IO Reply -- | Append string to the string-typed key -- -- RInt returned - the length of resulting string append :: Redis -> String -> String -> IO Reply -- | Add string value to the head of the list-type key -- -- ROk returned or RError if key is not a list rpush :: Redis -> String -> String -> IO Reply -- | Add string value to the tail of the list-type key -- -- ROk returned or RError if key is not a list lpush :: Redis -> String -> String -> IO Reply -- | Return lenght of the list. Note that for not-existing keys it returns -- zero length. -- -- RInt returned or RError if key is not a list llen :: Redis -> String -> IO Reply -- | Return the specified range of list elements. List indexed from 0 to -- (llen - 1). lrange returns slice including "from" and "to" elements, -- eg. lrange 0 2 will return the first three elements of the list. -- -- Parameters "from" and "to" may also be negative. If so it will counts -- as offset from end ot the list. eg. -1 - is the last element of the -- list, -2 - is the second from the end and so on. -- -- RMulti filled with RBulk returned lrange :: Redis -> String -> (Int, Int) -> IO Reply -- | Trim list so that it will contain only the specified range of -- elements. -- -- ROk returned ltrim :: Redis -> String -> (Int, Int) -> IO Reply -- | Return the specified element of the list by its index -- -- RBulk returned lindex :: Redis -> String -> Int -> IO Reply -- | Set the list's value indexed by an index to the new value -- -- ROk returned if element was set and RError if index is out of range or -- key is not a list lset :: Redis -> String -> Int -> String -> IO Reply -- | Remove the first count occurrences of the value element -- from the list -- -- RInt returned - the number of elements removed lrem :: Redis -> String -> Int -> String -> IO Reply -- | Atomically return and remove the first element of the list -- -- RBulk returned lpop :: Redis -> String -> IO Reply -- | Atomically return and remove the last element of the list -- -- RBulk returned rpop :: Redis -> String -> IO Reply -- | Atomically return and remove the last (tail) element of the source -- list, and push the element as the first (head) element of the -- destination list -- -- RBulk returned rpoplpush :: Redis -> String -> String -> IO Reply -- | Blocking lpop -- -- For more information see -- http://code.google.com/p/redis/wiki/BlpopCommand -- -- RMulti returned filled with key name and popped value blpop :: Redis -> [String] -> Int -> IO Reply -- | Blocking rpop -- -- For more information see -- http://code.google.com/p/redis/wiki/BlpopCommand -- -- RMulti returned filled with key name and popped value brpop :: Redis -> [String] -> Int -> IO Reply -- | Add the specified member to the set value stored at key -- -- (RInt 1) returned if element was added and (RInt 0) if element was -- already a member of the set sadd :: Redis -> String -> String -> IO Reply -- | Remove the specified member from the set value stored at key -- -- (RInt 1) returned if element was removed and (RInt 0) if element is -- not a member of the set srem :: Redis -> String -> String -> IO Reply -- | Remove a random element from a Set returning it as return value -- -- RBulk returned spop :: Redis -> String -> IO Reply -- | Move the specifided member from one set to another -- -- (RInt 1) returned if element was moved and (RInt 0) if element is not -- a member of the source set smove :: Redis -> String -> String -> String -> IO Reply -- | Return the number of elements of the set. If key doesn't exists 0 -- returned. -- -- RInt returned scard :: Redis -> String -> IO Reply -- | Test if element is member of the set. If key doesn't exists 0 -- returned. -- -- (RInt 1) returned if element is member of the set and (RInt 0) -- otherwise sismember :: Redis -> String -> IO Reply -- | Return all the members (elements) of the set -- -- RMulti filled with RBulk returned smembers :: Redis -> String -> IO Reply -- | Return a random element from a set -- -- RBulk returned srandmember :: Redis -> String -> IO Reply -- | Return the members of a set resulting from the intersection of all the -- specifided sets -- -- RMulti filled with RBulk returned sinter :: Redis -> [String] -> IO Reply -- | The same as sinter but instead of being returned the resulting -- set is stored -- -- ROk returned sinterStore :: Redis -> String -> [String] -> IO Reply -- | Return the members of a set resulting from the union of all the -- specifided sets -- -- RMulti filled with RBulk returned sunion :: Redis -> [String] -> IO Reply -- | The same as sunion but instead of being returned the resulting -- set is stored -- -- ROk returned sunionStore :: Redis -> String -> [String] -> IO Reply -- | Return the members of a set resulting from the difference between the -- first set provided and all the successive sets -- -- RMulti filled with RBulk returned sdiff :: Redis -> [String] -> IO Reply -- | The same as sdiff but instead of being returned the resulting -- set is stored -- -- ROk returned sdiffStore :: Redis -> String -> [String] -> IO Reply -- | Add the specified member having the specifeid score to the sorted set -- -- (RInt 1) returned if new element was added and (RInt 0) if that -- element was already a member of the sortet set and the score was -- updated zadd :: Redis -> String -> Double -> String -> IO Reply -- | Remove the specified member from the sorted set -- -- (RInt 1) returned if element was removed and (RInt 0) if element was -- not a member of the sorted set zrem :: Redis -> String -> String -> IO Reply -- | If member already in the sorted set adds the increment -- to its score and updates the position of the element in the sorted set -- accordingly. If member does not exist in the sorted set it is added -- with increment as score (that is, like if the previous score was -- virtually zero). The new score of the member is returned. -- -- RBulk returned zincrBy :: Redis -> String -> Double -> String -> IO Reply -- | Return the specified elements of the sorted set. Start and end are -- zero-based indexes. WITHSCORES paramenter indicates if it's needed to -- return elements with its scores or not. If WITHSCORES is True then the -- resulting list will be composed of value1, score1, value2, score2 and -- so on. -- -- RMulti filled with RBulk returned zrange :: Redis -> String -> (Int, Int) -> Bool -> IO Reply -- | Return the specified elements of the sorted set at the specified key. -- The elements are considered sorted from the highest to the lowerest -- score -- -- RMulti filled with RBulk returned zrevrange :: Redis -> String -> (Int, Int) -> Bool -> IO Reply -- | Return the all the elements in the sorted set with a score that lays -- within a given interval -- -- RMulti filled with RBulk returned zrangebyscore :: (IsInterval i Double) => Redis -> String -> i -> Bool -> IO Reply -- | Count a number of elements of the sorted set with a score that lays -- within a given interval -- -- RInt returned zcount :: (IsInterval i Double) => Redis -> String -> i -> IO Reply -- | Remove all the elements in the sorted set with a score that lays -- within a given interval -- -- RInt returned - the number of elements removed zremrangebyscore :: Redis -> String -> (Double, Double) -> IO Reply -- | Return the sorted set cardinality (number of elements) -- -- RInt returned zcard :: Redis -> String -> IO Reply -- | Return the score of the specified element of the sorted set -- -- RBulk returned zscore :: Redis -> String -> String -> IO Reply -- | Sort the elements contained in the List, Set, or Sorted Set -- -- for more information see -- http://code.google.com/p/redis/wiki/SortCommand -- -- RMulti filled with RBulk returned sort :: Redis -> String -> SortOptions -> IO Reply -- | Shortcut for the sort with some get_obj and constant -- sort_by options -- -- RMulti filled with RBulk returned listRelated :: Redis -> String -> String -> (Int, Int) -> IO Reply -- | Save the whole dataset on disk -- -- ROk returned save :: Redis -> IO Reply -- | Save the DB in background -- -- ROk returned bgsave :: Redis -> IO Reply -- | Return the UNIX TIME of the last DB save executed with success -- -- RInt returned lastsave :: Redis -> IO Reply -- | Rewrites the Append Only File in background -- -- ROk returned bgrewriteaof :: Redis -> IO Reply instance (Show a) => Show (Interval a) instance Show Reply instance Eq Reply instance Show Redis instance Eq Redis instance IsInterval [a] a instance IsInterval (a, a) a instance IsInterval (Interval a) a -- | Monadic wrapper for Database.Redis.Redis module Database.Redis.Monad class (MonadIO m) => WithRedis m getRedis :: (WithRedis m) => m (Redis) setRedis :: (WithRedis m) => Redis -> m () -- | Redis connection descriptor data Redis Redis :: (String, String) -> Handle -> Redis -- | hostname and port pair server :: Redis -> (String, String) -- | real network connection handle :: Redis -> Handle -- | Redis reply variants data Reply -- | Timeout. Currently unused RTimeout :: Reply -- | "Ok" reply ROk :: Reply -- | Reply for the ping command RPong :: Reply -- | Used inside multi-exec block RQueued :: Reply -- | Some kind of server-side error RError :: String -> Reply -- | Simple oneline reply RInline :: String -> Reply -- | Integer reply RInt :: Int -> Reply -- | Multiline reply RBulk :: (Maybe String) -> Reply -- | Complex reply. It may consists of various type of replys RMulti :: (Maybe [Reply]) -> Reply -- | Interval representation data Interval a -- | closed interval [a, b] Closed :: a -> a -> Interval a -- | open interval (a, b) Open :: a -> a -> Interval a -- | left-open interval (a, b] LeftOpen :: a -> a -> Interval a -- | right-open interval [a, b) RightOpen :: a -> a -> Interval a -- | Class for conversion value to Interval -- -- Definied instances is: -- -- class IsInterval i a | i -> a toInterval :: (IsInterval i a) => i -> Interval a -- | Options data type for the sort command data SortOptions SortOptions :: Bool -> (Int, Int) -> Bool -> String -> [String] -> String -> SortOptions -- | sort with descending order desc :: SortOptions -> Bool -- | return (from, to) elements limit :: SortOptions -> (Int, Int) -- | sort alphabetically alpha :: SortOptions -> Bool -- | sort by value from this key sort_by :: SortOptions -> String -- | return this keys values get_obj :: SortOptions -> [String] -- | store result to this key store :: SortOptions -> String -- | Default options for the sort command sortDefaults :: SortOptions -- | Unwraps RInline reply. -- -- Throws an exception when called with something different from RInline fromRInline :: (Monad m) => Reply -> m String -- | Unwraps RBulk reply. -- -- Throws an exception when called with something different from RBulk fromRBulk :: (Monad m) => Reply -> m (Maybe String) -- | Unwraps RMulti reply -- -- Throws an exception when called with something different from RMulti fromRMulti :: (Monad m) => Reply -> m (Maybe [Reply]) -- | Unwraps RMulti reply filled with RBulk -- -- Throws an exception when called with something different from RMulti fromRMultiBulk :: (Monad m) => Reply -> m (Maybe [Maybe String]) -- | Unwraps RInt reply -- -- Throws an exception when called with something different from RInt fromRInt :: (Monad m) => Reply -> m Int -- | Unwraps ROk reply -- -- Throws an exception when called with something different from ROk fromROk :: (Monad m) => Reply -> m () -- | Unwraps every non-error reply -- -- Throws an exception when called with something different from RMulti noError :: (Monad m) => Reply -> m () -- | a (0, -1) range - takes all element from a list in lrange, zrange and -- so on takeAll :: (Int, Int) -- | just a localhost localhost :: String -- | default Redis port defaultPort :: String connect :: (WithRedis m) => String -> String -> m () disconnect :: (WithRedis m) => m () isConnected :: (WithRedis m) => m Bool ping :: (WithRedis m) => m Reply auth :: (WithRedis m) => String -> m Reply quit :: (WithRedis m) => m () shutdown :: (WithRedis m) => m Reply multi :: (WithRedis m) => m Reply exec :: (WithRedis m) => m Reply run_multi :: (WithRedis m) => [m Reply] -> m Reply exists :: (WithRedis m) => String -> m Reply del :: (WithRedis m) => String -> m Reply getType :: (WithRedis m) => String -> m Reply keys :: (WithRedis m) => String -> m Reply randomKey :: (WithRedis m) => m Reply rename :: (WithRedis m) => String -> String -> m Reply renameNx :: (WithRedis m) => String -> String -> m Reply dbsize :: (WithRedis m) => m Reply expire :: (WithRedis m) => String -> Int -> m Reply expireAt :: (WithRedis m) => String -> Int -> m Reply ttl :: (WithRedis m) => String -> m Reply select :: (WithRedis m) => Int -> m Reply move :: (WithRedis m) => String -> Int -> m Reply flushDb :: (WithRedis m) => m Reply flushAll :: (WithRedis m) => m Reply info :: (WithRedis m) => m Reply set :: (WithRedis m) => String -> String -> m Reply setNx :: (WithRedis m) => String -> String -> m Reply mSet :: (WithRedis m) => [(String, String)] -> m Reply mSetNx :: (WithRedis m) => [(String, String)] -> m Reply get :: (WithRedis m) => String -> m Reply getSet :: (WithRedis m) => String -> String -> m Reply mGet :: (WithRedis m) => [String] -> m Reply incr :: (WithRedis m) => String -> m Reply incrBy :: (WithRedis m) => String -> Int -> m Reply decr :: (WithRedis m) => String -> m Reply decrBy :: (WithRedis m) => String -> Int -> m Reply append :: (WithRedis m) => String -> String -> m Reply rpush :: (WithRedis m) => String -> String -> m Reply lpush :: (WithRedis m) => String -> String -> m Reply llen :: (WithRedis m) => String -> m Reply lrange :: (WithRedis m) => String -> (Int, Int) -> m Reply ltrim :: (WithRedis m) => String -> (Int, Int) -> m Reply lindex :: (WithRedis m) => String -> Int -> m Reply lset :: (WithRedis m) => String -> Int -> String -> m Reply lrem :: (WithRedis m) => String -> Int -> String -> m Reply lpop :: (WithRedis m) => String -> m Reply rpop :: (WithRedis m) => String -> m Reply rpoplpush :: (WithRedis m) => String -> String -> m Reply blpop :: (WithRedis m) => [String] -> Int -> m Reply brpop :: (WithRedis m) => [String] -> Int -> m Reply sadd :: (WithRedis m) => String -> String -> m Reply srem :: (WithRedis m) => String -> String -> m Reply spop :: (WithRedis m) => String -> m Reply smove :: (WithRedis m) => String -> String -> String -> m Reply scard :: (WithRedis m) => String -> m Reply sismember :: (WithRedis m) => String -> m Reply smembers :: (WithRedis m) => String -> m Reply srandmember :: (WithRedis m) => String -> m Reply sinter :: (WithRedis m) => [String] -> m Reply sinterStore :: (WithRedis m) => String -> [String] -> m Reply sunion :: (WithRedis m) => [String] -> m Reply sunionStore :: (WithRedis m) => String -> [String] -> m Reply sdiff :: (WithRedis m) => [String] -> m Reply sdiffStore :: (WithRedis m) => String -> [String] -> m Reply zadd :: (WithRedis m) => String -> Double -> String -> m Reply zrem :: (WithRedis m) => String -> String -> m Reply zincrBy :: (WithRedis m) => String -> Double -> String -> m Reply zrange :: (WithRedis m) => String -> (Int, Int) -> Bool -> m Reply zrevrange :: (WithRedis m) => String -> (Int, Int) -> Bool -> m Reply zrangebyscore :: (WithRedis m, IsInterval i Double) => String -> i -> Bool -> m Reply zcount :: (WithRedis m, IsInterval i Double) => String -> i -> m Reply zremrangebyscore :: (WithRedis m) => String -> (Double, Double) -> m Reply zcard :: (WithRedis m) => String -> m Reply zscore :: (WithRedis m) => String -> String -> m Reply sort :: (WithRedis m) => String -> SortOptions -> m Reply listRelated :: (WithRedis m) => String -> String -> (Int, Int) -> m Reply save :: (WithRedis m) => m Reply bgsave :: (WithRedis m) => m Reply lastsave :: (WithRedis m) => m Reply bgrewriteaof :: (WithRedis m) => m Reply -- | This module is mainly an example of posible WithRedis -- implementation module Database.Redis.Monad.State -- | Trivial WithRedis instance storing Redis descriptor in StateT type RedisM = StateT Redis IO runWithRedis :: Redis -> (RedisM a) -> IO a instance WithRedis RedisM -- | Emulating locking primitives module Database.Redis.Utils.Lock -- | Acquire lock. This function is not reentrant so thread can be locked -- by itself if it try to acquire the same lock before it was released. acquire :: Redis -> String -> Int -> Int -> IO Bool acquire' :: Redis -> String -> Int -> IO Bool acquireOnce :: Redis -> String -> IO Bool -- | acquire with default last parameter set to 50 milliseconds -- -- Try to acquire lock once and return result without any timeout -- -- Release lock. There is no any guarantees that lock was acquired in -- this thread. Just release this lock and go forth. release :: Redis -> String -> IO () -- | Same as Database.Redis.Utils.Lock but with monadic wrapped module Database.Redis.Utils.Monad.Lock acquire :: (WithRedis m) => String -> Int -> Int -> m Bool acquire' :: (WithRedis m) => String -> Int -> m Bool acquireOnce :: (WithRedis m) => String -> m Bool release :: (WithRedis m) => String -> m ()