-- 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. Note that this library -- supports the most recent (actually the git one) version of Redis -- protocol. Most of the functions will work correctly with stable -- version but not all. -- -- Changes from v0.4: -- -- @package redis @version 0.5 module Database.Redis.ByteStringClass -- | Utility class for conversion to and from Strict ByteString class BS a toBS :: (BS a) => a -> ByteString fromBS :: (BS a) => ByteString -> a instance BS () instance BS Double instance BS Int instance BS String instance BS ByteString instance BS ByteString -- | Main Redis API and protocol implementation module Database.Redis.Redis -- | Redis connection descriptor data Redis -- | Redis reply variants data (BS s) => Reply s -- | Timeout. Currently unused RTimeout :: Reply s -- | "Ok" reply ROk :: Reply s -- | Reply for the ping command RPong :: Reply s -- | Used inside multi-exec block RQueued :: Reply s -- | Some kind of server-side error RError :: String -> Reply s -- | Simple oneline reply RInline :: s -> Reply s -- | Integer reply RInt :: Int -> Reply s -- | Multiline reply RBulk :: (Maybe s) -> Reply s -- | Complex reply. It may consists of various type of replys RMulti :: (Maybe [Reply s]) -> Reply s data (BS s) => Message s MSubscribe :: s -> Int -> Message s MUnsubscribe :: s -> Int -> Message s MMessage :: s -> s -> Message s -- | 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 (BS s) => SortOptions s SortOptions :: Bool -> (Int, Int) -> Bool -> s -> [s] -> s -> SortOptions s -- | sort with descending order desc :: SortOptions s -> Bool -- | return (from, to) elements limit :: SortOptions s -> (Int, Int) -- | sort alphabetically alpha :: SortOptions s -> Bool -- | sort by value from this key sort_by :: SortOptions s -> s -- | return this keys values get_obj :: SortOptions s -> [s] -- | store result to this key store :: SortOptions s -> s data Aggregate SUM :: Aggregate MIN :: Aggregate MAX :: Aggregate -- | Default options for the sort command sortDefaults :: SortOptions ByteString -- | Unwraps RInline reply. -- -- Throws an exception when called with something different from RInline fromRInline :: (Monad m, BS s) => Reply s -> m s -- | Unwraps RBulk reply. -- -- Throws an exception when called with something different from RBulk fromRBulk :: (Monad m, BS s) => Reply s -> m (Maybe s) -- | Unwraps RMulti reply -- -- Throws an exception when called with something different from RMulti fromRMulti :: (Monad m, BS s) => Reply s -> m (Maybe [Reply s]) -- | Unwraps RMulti reply filled with RBulk -- -- Throws an exception when called with something different from RMulti fromRMultiBulk :: (Monad m, BS s) => Reply s -> m (Maybe [Maybe s]) -- | Unwraps RInt reply -- -- Throws an exception when called with something different from RInt fromRInt :: (Monad m, BS s) => Reply s -> m Int -- | Unwraps ROk reply -- -- Throws an exception when called with something different from ROk fromROk :: (Monad m, BS s) => Reply s -> m () -- | Unwraps every non-error reply -- -- Throws an exception when called with something different from RMulti noError :: (Monad m, BS s) => Reply s -> m () -- | Parse Reply as a Message -- -- Throws an exception on parse error parseMessage :: (Monad m, BS s) => Reply ByteString -> m (Message s) -- | 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 :: (BS s) => Redis -> s -> IO (Reply ()) -- | Quit and close connection quit :: Redis -> IO () -- | Stop all the clients, save the DB, then quit the server shutdown :: Redis -> IO () -- | Begin the multi-exec block -- -- ROk returned multi :: Redis -> IO (Reply ()) -- | Execute queued commands -- -- RMulti returned - replys for all executed commands exec :: (BS s) => Redis -> IO (Reply s) -- | Discard queued commands without execution -- -- ROk returned discard :: Redis -> IO (Reply ()) -- | Run commands within multi-exec block -- -- RMulti returned - replys for all executed commands run_multi :: (BS s) => Redis -> [IO (Reply ())] -> IO (Reply s) -- | Test if the key exists -- -- (RInt 1) returned if the key exists and (RInt 0) otherwise exists :: (BS s) => Redis -> s -> IO (Reply Int) -- | Remove the key -- -- (RInt 0) returned if no keys were removed or (RInt n) with removed -- keys count del :: (BS s) => Redis -> s -> IO (Reply Int) -- | Return the type of the value stored at key in form of a string -- -- RInline with one of none, string, list, -- set, zset, hash returned getType :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | Returns all the keys matching the glob-style pattern -- -- RMulti filled with RBulk returned keys :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | Return random key name -- -- RInline returned randomKey :: (BS s) => Redis -> IO (Reply s) -- | Rename the key. If key with that name exists it'll be overwritten. -- -- ROk returned rename :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply ()) -- | Rename the key if no keys with destination name exists. -- -- (RInt 1) returned if key was renamed and (RInt 0) otherwise renameNx :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | Get the number of keys in the currently selected database -- -- RInt returned dbsize :: Redis -> IO (Reply Int) -- | 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 :: (BS s) => Redis -> s -> Int -> IO (Reply Int) -- | 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 :: (BS s) => Redis -> s -> Int -> IO (Reply Int) -- | Return the remining time to live of the key or -1 if key has no -- associated timeout -- -- RInt returned ttl :: (BS s) => Redis -> s -> IO (Reply Int) -- | 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 :: (BS s) => Redis -> s -> Int -> IO (Reply Int) -- | 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 :: (BS s) => Redis -> IO (Reply s) -- | Set the string value as value of the key -- -- ROk returned set :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply ()) -- | Set the key value if key does not exists -- -- (RInt 1) returned if key was set and (RInt 0) otherwise setNx :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | Atomically set multiple keys -- -- ROk returned mSet :: (BS s1, BS s2) => Redis -> [(s1, s2)] -> IO (Reply ()) -- | Atomically set multiple keys if none of them exists. -- -- (RInt 1) returned if all keys was set and (RInt 0) otherwise mSetNx :: (BS s1, BS s2) => Redis -> [(s1, s2)] -> IO (Reply Int) -- | Get the value of the specified key. -- -- RBulk returned get :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | Atomically set this value and return the old value -- -- RBulk returned getSet :: (BS s1, BS s2, BS s3) => Redis -> s1 -> s2 -> IO (Reply s3) -- | Get the values of all specified keys -- -- RMulti filled with RBulk replys returned mGet :: (BS s1, BS s2) => Redis -> [s1] -> IO (Reply s2) -- | Increment the key value by one -- -- RInt returned with new key value incr :: (BS s) => Redis -> s -> IO (Reply Int) -- | Increment the key value by N -- -- RInt returned with new key value incrBy :: (BS s) => Redis -> s -> Int -> IO (Reply Int) -- | Decrement the key value by one -- -- RInt returned with new key value decr :: (BS s) => Redis -> s -> IO (Reply Int) -- | Decrement the key value by N -- -- RInt returned with new key value decrBy :: (BS s) => Redis -> s -> Int -> IO (Reply Int) -- | Append string to the string-typed key -- -- RInt returned - the length of resulting string append :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | Get a substring. Indexes are zero-based. -- -- RBulk returned substr :: (BS s1, BS s2) => Redis -> s1 -> (Int, Int) -> IO (Reply s2) -- | Add string value to the head of the list-type key. New list length -- returned -- -- RInt returned rpush :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | Add string value to the tail of the list-type key. New list length -- returned -- -- RInt returned lpush :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | 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 :: (BS s) => Redis -> s -> IO (Reply Int) -- | 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 :: (BS s1, BS s2) => Redis -> s1 -> (Int, Int) -> IO (Reply s2) -- | Trim list so that it will contain only the specified range of -- elements. -- -- ROk returned ltrim :: (BS s) => Redis -> s -> (Int, Int) -> IO (Reply ()) -- | Return the specified element of the list by its index -- -- RBulk returned lindex :: (BS s1, BS s2) => Redis -> s1 -> Int -> IO (Reply s2) -- | 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 :: (BS s1, BS s2) => Redis -> s1 -> Int -> s2 -> IO (Reply ()) -- | Remove the first count occurrences of the value element -- from the list -- -- RInt returned - the number of elements removed lrem :: (BS s1, BS s2) => Redis -> s1 -> Int -> s2 -> IO (Reply Int) -- | Atomically return and remove the first element of the list -- -- RBulk returned lpop :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | Atomically return and remove the last element of the list -- -- RBulk returned rpop :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | 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 :: (BS s1, BS s2, BS s3) => Redis -> s1 -> s2 -> IO (Reply s3) -- | Blocking lpop -- -- For more information see -- http://code.google.com/p/redis/wiki/BlpopCommand -- -- RMulti returned filled with key name and popped value blpop :: (BS s1, BS s2) => Redis -> [s1] -> Int -> IO (Reply s2) -- | Blocking rpop -- -- For more information see -- http://code.google.com/p/redis/wiki/BlpopCommand -- -- RMulti returned filled with key name and popped value brpop :: (BS s1, BS s2) => Redis -> [s1] -> Int -> IO (Reply s2) -- | 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 :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | 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 :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | Remove a random element from a Set returning it as return value -- -- RBulk returned spop :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | 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 :: (BS s1, BS s2, BS s3) => Redis -> s1 -> s2 -> s3 -> IO (Reply Int) -- | Return the number of elements of the set. If key doesn't exists 0 -- returned. -- -- RInt returned scard :: (BS s) => Redis -> s -> IO (Reply Int) -- | 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 :: (BS s) => Redis -> s -> IO (Reply Int) -- | Return all the members (elements) of the set -- -- RMulti filled with RBulk returned smembers :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | Return a random element from a set -- -- RBulk returned srandmember :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | Return the members of a set resulting from the intersection of all the -- specifided sets -- -- RMulti filled with RBulk returned sinter :: (BS s1, BS s2) => Redis -> [s1] -> IO (Reply s2) -- | The same as sinter but instead of being returned the resulting -- set is stored -- -- ROk returned sinterStore :: (BS s1, BS s2) => Redis -> s1 -> [s2] -> IO (Reply ()) -- | Return the members of a set resulting from the union of all the -- specifided sets -- -- RMulti filled with RBulk returned sunion :: (BS s1, BS s2) => Redis -> [s1] -> IO (Reply s2) -- | The same as sunion but instead of being returned the resulting -- set is stored -- -- ROk returned sunionStore :: (BS s1, BS s2) => Redis -> s1 -> [s2] -> 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 :: (BS s1, BS s2) => Redis -> [s1] -> IO (Reply s2) -- | The same as sdiff but instead of being returned the resulting -- set is stored -- -- ROk returned sdiffStore :: (BS s1, BS s2) => Redis -> s1 -> [s2] -> 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 :: (BS s1, BS s2) => Redis -> s1 -> Double -> s2 -> IO (Reply Int) -- | 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 :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | 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 :: (BS s1, BS s2, BS s3) => Redis -> s1 -> Double -> s2 -> IO (Reply s3) -- | 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 :: (BS s1, BS s2) => Redis -> s1 -> (Int, Int) -> Bool -> IO (Reply s2) -- | 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 :: (BS s1, BS s2) => Redis -> s1 -> (Int, Int) -> Bool -> IO (Reply s2) -- | 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, BS s1, BS s2) => Redis -> s1 -> i -> Bool -> IO (Reply s2) -- | Count a number of elements of the sorted set with a score that lays -- within a given interval -- -- RInt returned zcount :: (IsInterval i Double, BS s) => Redis -> s -> i -> IO (Reply Int) -- | Remove all the elements in the sorted set with a score that lays -- within a given interval. For now this command doesn't supports open -- and semi-open intervals -- -- RInt returned - the number of elements removed zremrangebyscore :: (BS s) => Redis -> s -> (Double, Double) -> IO (Reply Int) -- | Return the sorted set cardinality (number of elements) -- -- RInt returned zcard :: (BS s) => Redis -> s -> IO (Reply Int) -- | Return the score of the specified element of the sorted set -- -- RBulk returned zscore :: (BS s1, BS s2, BS s3) => Redis -> s1 -> s2 -> IO (Reply s3) -- | Returns sorted set element sequence number counting from zero -- -- RInt returned zrank :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | Returns sorted set element sequence number for reversed sort order -- -- RInt returned zrevrank :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | Remove elements from the sorted set with rank lays within a given -- interval. -- -- RInt returned - the number of elements removed zremrangebyrank :: (BS s) => Redis -> s -> (Int, Int) -> IO (Reply Int) -- | Create a union of provided sorted sets and store it at -- destination key -- -- If weights is not null then scores of sorted sets used with -- corresponding weights. If so lenght of weights must be the same -- as length of sources. -- -- Aggregate is an option how to aggregate resulting scores. -- -- RInt returned - the number of elements in the resulting set. zunion :: (BS s1, BS s2) => Redis -> s1 -> [s2] -> [Double] -> Aggregate -> IO (Reply Int) -- | Create an intersectoin of provided sorted sets and store it at -- destination key -- -- If weights is not null then scores of sorted sets used with -- corresponding weights. If so lenght of weights must be the same -- as length of sources. -- -- Aggregate is an option how to aggregate resulting scores. -- -- RInt returned - the number of elements in the resulting set. zinter :: (BS s1, BS s2) => Redis -> s1 -> [s2] -> [Double] -> Aggregate -> IO (Reply Int) -- | Set the specified hash field to the specified value -- -- (RInt 0 returned if field value was updated and (RInt 1) if new field -- created hset :: (BS s1, BS s2, BS s3) => Redis -> s1 -> s2 -> s3 -> IO (Reply Int) -- | Return value associated with specified field from hash -- -- RBulk returned hget :: (BS s1, BS s2, BS s3) => Redis -> s1 -> s2 -> IO (Reply s3) -- | Remove field from a hash -- -- (RInt 1) returned if field was removed and (RInt 0) otherwise hdel :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | Atomically sets multiple fields within a hash-typed key -- -- ROk returned hmset :: (BS s1, BS s2, BS s3) => Redis -> s1 -> [(s2, s3)] -> IO (Reply ()) -- | Get the values of all specified fields from the hash-typed key -- -- RMulti filled with RBulk replys returned hmget :: (BS s1, BS s2, BS s3) => Redis -> s1 -> [s2] -> IO (Reply s3) -- | Increment the field value within a hash by N -- -- RInt returned with new key value hincrby :: (BS s1, BS s2) => Redis -> s1 -> s2 -> Int -> IO (Reply Int) -- | Test if hash contains the specified field -- -- (RInt 1) returned if fiels exists and (RInt 0) otherwise hexists :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | Return the number of fields contained in the specified hash -- -- RInt returned hlen :: (BS s) => Redis -> s -> IO (Reply Int) -- | Return all the field names the hash holding -- -- RMulti field with RBulk returned hkeys :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | Return all the associated values the hash holding -- -- RMulti field with RBulk returned hvals :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | Return all the field names and associated values the hash holding in -- form of [field1, value1, field2, value2...] -- -- RMulti field with RBulk returned hgetall :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2) -- | 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 :: (BS s1, BS s2, BS s3) => Redis -> s1 -> SortOptions s2 -> IO (Reply s3) -- | Shortcut for the sort with some get_obj and constant -- sort_by options -- -- RMulti filled with RBulk returned listRelated :: (BS s1, BS s2, BS s3) => Redis -> s1 -> s2 -> (Int, Int) -> IO (Reply s3) -- | Get a number of subscribed channels on this connection -- -- It doesn't run any redis commands, number of subscribtions is taken -- from internal connection state subscribed :: Redis -> IO Int -- | Subscribe to channels -- -- list of Message with subscribtion information returned subscribe :: (BS s1, BS s2) => Redis -> [s1] -> IO [Message s2] -- | Unsubscribe from channels -- -- list of Message with subscribtion information returned unsubscribe :: (BS s1, BS s2) => Redis -> [s1] -> IO [Message s2] -- | Publish message to target channel -- -- RInt returned - a number of clients publish :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int) -- | Wait for a messages. -- -- Important! Client will be blocken untill some message recieved! -- -- Message returned listen :: (BS s) => Redis -> IO (Maybe (Message s)) -- | 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 Int) -- | Rewrites the Append Only File in background -- -- ROk returned bgrewriteaof :: Redis -> IO (Reply ()) instance Eq Aggregate instance Show Aggregate instance (Show a) => Show (Interval a) 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 :: MVar (Maybe (ThreadId, Int)) -> MVar () -> IORef RedisState -> Redis r_lock_cnt :: Redis -> MVar (Maybe (ThreadId, Int)) r_lock :: Redis -> MVar () r_st :: Redis -> IORef RedisState -- | Redis reply variants data (BS s) => Reply s -- | Timeout. Currently unused RTimeout :: Reply s -- | "Ok" reply ROk :: Reply s -- | Reply for the ping command RPong :: Reply s -- | Used inside multi-exec block RQueued :: Reply s -- | Some kind of server-side error RError :: String -> Reply s -- | Simple oneline reply RInline :: s -> Reply s -- | Integer reply RInt :: Int -> Reply s -- | Multiline reply RBulk :: (Maybe s) -> Reply s -- | Complex reply. It may consists of various type of replys RMulti :: (Maybe [Reply s]) -> Reply s data (BS s) => Message s MSubscribe :: s -> Int -> Message s MUnsubscribe :: s -> Int -> Message s MMessage :: s -> s -> Message s -- | 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 (BS s) => SortOptions s SortOptions :: Bool -> (Int, Int) -> Bool -> s -> [s] -> s -> SortOptions s -- | sort with descending order desc :: SortOptions s -> Bool -- | return (from, to) elements limit :: SortOptions s -> (Int, Int) -- | sort alphabetically alpha :: SortOptions s -> Bool -- | sort by value from this key sort_by :: SortOptions s -> s -- | return this keys values get_obj :: SortOptions s -> [s] -- | store result to this key store :: SortOptions s -> s data Aggregate SUM :: Aggregate MIN :: Aggregate MAX :: Aggregate -- | Default options for the sort command sortDefaults :: SortOptions ByteString -- | Unwraps RInline reply. -- -- Throws an exception when called with something different from RInline fromRInline :: (Monad m, BS s) => Reply s -> m s -- | Unwraps RBulk reply. -- -- Throws an exception when called with something different from RBulk fromRBulk :: (Monad m, BS s) => Reply s -> m (Maybe s) -- | Unwraps RMulti reply -- -- Throws an exception when called with something different from RMulti fromRMulti :: (Monad m, BS s) => Reply s -> m (Maybe [Reply s]) -- | Unwraps RMulti reply filled with RBulk -- -- Throws an exception when called with something different from RMulti fromRMultiBulk :: (Monad m, BS s) => Reply s -> m (Maybe [Maybe s]) -- | Unwraps RInt reply -- -- Throws an exception when called with something different from RInt fromRInt :: (Monad m, BS s) => Reply s -> m Int -- | Unwraps ROk reply -- -- Throws an exception when called with something different from ROk fromROk :: (Monad m, BS s) => Reply s -> m () -- | Unwraps every non-error reply -- -- Throws an exception when called with something different from RMulti noError :: (Monad m, BS s) => Reply s -> m () -- | Parse Reply as a Message -- -- Throws an exception on parse error parseMessage :: (Monad m, BS s) => Reply ByteString -> m (Message s) -- | 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 () multi :: (WithRedis m) => m (Reply ()) exec :: (WithRedis m, BS s) => m (Reply s) discard :: (WithRedis m) => m (Reply ()) run_multi :: (MonadCatchIO m, WithRedis m, BS s) => [m (Reply ())] -> m (Reply s) exists :: (WithRedis m, BS s) => s -> m (Reply Int) del :: (WithRedis m, BS s) => s -> m (Reply Int) getType :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) keys :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) randomKey :: (WithRedis m, BS s) => m (Reply s) rename :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply ()) renameNx :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) dbsize :: (WithRedis m) => m (Reply Int) expire :: (WithRedis m, BS s) => s -> Int -> m (Reply Int) expireAt :: (WithRedis m, BS s) => s -> Int -> m (Reply Int) ttl :: (WithRedis m, BS s) => s -> m (Reply Int) select :: (WithRedis m) => Int -> m (Reply ()) move :: (WithRedis m, BS s) => s -> Int -> m (Reply Int) flushDb :: (WithRedis m) => m (Reply ()) flushAll :: (WithRedis m) => m (Reply ()) info :: (WithRedis m, BS s) => m (Reply s) set :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply ()) setNx :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) mSet :: (WithRedis m, BS s1, BS s2) => [(s1, s2)] -> m (Reply ()) mSetNx :: (WithRedis m, BS s1, BS s2) => [(s1, s2)] -> m (Reply Int) get :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) getSet :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> s2 -> m (Reply s3) mGet :: (WithRedis m, BS s1, BS s2) => [s1] -> m (Reply s2) incr :: (WithRedis m, BS s) => s -> m (Reply Int) incrBy :: (WithRedis m, BS s) => s -> Int -> m (Reply Int) decr :: (WithRedis m, BS s) => s -> m (Reply Int) decrBy :: (WithRedis m, BS s) => s -> Int -> m (Reply Int) append :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) substr :: (WithRedis m, BS s1, BS s2) => s1 -> (Int, Int) -> m (Reply s2) rpush :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) lpush :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) llen :: (WithRedis m, BS s) => s -> m (Reply Int) lrange :: (WithRedis m, BS s1, BS s2) => s1 -> (Int, Int) -> m (Reply s2) ltrim :: (WithRedis m, BS s) => s -> (Int, Int) -> m (Reply ()) lindex :: (WithRedis m, BS s1, BS s2) => s1 -> Int -> m (Reply s2) lset :: (WithRedis m, BS s1, BS s2) => s1 -> Int -> s2 -> m (Reply ()) lrem :: (WithRedis m, BS s1, BS s2) => s1 -> Int -> s2 -> m (Reply Int) lpop :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) rpop :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) rpoplpush :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> s2 -> m (Reply s3) blpop :: (WithRedis m, BS s1, BS s2) => [s1] -> Int -> m (Reply s2) brpop :: (WithRedis m, BS s1, BS s2) => [s1] -> Int -> m (Reply s2) sadd :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) srem :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) spop :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) smove :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> s2 -> s3 -> m (Reply Int) scard :: (WithRedis m, BS s) => s -> m (Reply Int) sismember :: (WithRedis m, BS s) => s -> m (Reply Int) smembers :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) srandmember :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) sinter :: (WithRedis m, BS s1, BS s2) => [s1] -> m (Reply s2) sinterStore :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> m (Reply ()) sunion :: (WithRedis m, BS s1, BS s2) => [s1] -> m (Reply s2) sunionStore :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> m (Reply ()) sdiff :: (WithRedis m, BS s1, BS s2) => [s1] -> m (Reply s2) sdiffStore :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> m (Reply ()) zadd :: (WithRedis m, BS s1, BS s2) => s1 -> Double -> s2 -> m (Reply Int) zrem :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) zincrBy :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> Double -> s2 -> m (Reply s3) zrange :: (WithRedis m, BS s1, BS s2) => s1 -> (Int, Int) -> Bool -> m (Reply s2) zrevrange :: (WithRedis m, BS s1, BS s2) => s1 -> (Int, Int) -> Bool -> m (Reply s2) zrangebyscore :: (WithRedis m, IsInterval i Double, BS s1, BS s2) => s1 -> i -> Bool -> m (Reply s2) zcount :: (WithRedis m, IsInterval i Double, BS s) => s -> i -> m (Reply Int) zremrangebyscore :: (WithRedis m, BS s) => s -> (Double, Double) -> m (Reply Int) zcard :: (WithRedis m, BS s) => s -> m (Reply Int) zscore :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> s2 -> m (Reply s3) zrank :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) zrevrank :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) zremrangebyrank :: (WithRedis m, BS s) => s -> (Int, Int) -> m (Reply Int) zunion :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> [Double] -> Aggregate -> m (Reply Int) zinter :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> [Double] -> Aggregate -> m (Reply Int) hset :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> s2 -> s3 -> m (Reply Int) hget :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> s2 -> m (Reply s3) hdel :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) hmset :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> [(s2, s3)] -> m (Reply ()) hmget :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> [s2] -> m (Reply s3) hincrby :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> Int -> m (Reply Int) hexists :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) hlen :: (WithRedis m, BS s) => s -> m (Reply Int) hkeys :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) hvals :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) hgetall :: (WithRedis m, BS s1, BS s2) => s1 -> m (Reply s2) sort :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> SortOptions s2 -> m (Reply s3) listRelated :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> s2 -> (Int, Int) -> m (Reply s3) subscribed :: (WithRedis m) => m Int subscribe :: (WithRedis m, BS s1, BS s2) => [s1] -> m [Message s2] unsubscribe :: (WithRedis m, BS s1, BS s2) => [s1] -> m [Message s2] publish :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int) listen :: (WithRedis m, BS s) => m (Maybe (Message s)) save :: (WithRedis m) => m (Reply ()) bgsave :: (WithRedis m) => m (Reply ()) lastsave :: (WithRedis m) => m (Reply Int) 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 :: (BS s) => Redis -> s -> Int -> Int -> IO Bool acquire' :: (BS s) => Redis -> s -> Int -> IO Bool acquireOnce :: (BS s1) => Redis -> s1 -> 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 :: (BS s) => Redis -> s -> IO () -- | Same as Database.Redis.Utils.Lock but with monadic wrapped module Database.Redis.Utils.Monad.Lock acquire :: (WithRedis m, BS s) => s -> Int -> Int -> m Bool acquire' :: (WithRedis m, BS s) => s -> Int -> m Bool acquireOnce :: (WithRedis m, BS b) => b -> m Bool release :: (WithRedis m, BS s) => s -> m ()