Safe Haskell | None |
---|

Monadic wrapper for Database.Redis.Redis

- class MonadIO m => WithRedis m where
- data Redis = Redis {}
- data Reply s
- data Message s
- = MSubscribe s Int
- | MUnsubscribe s Int
- | MPSubscribe s Int
- | MPUnsubscribe s Int
- | MMessage s s
- | MPMessage s s s

- data LInsertDirection
- data Interval a
- class IsInterval i a | i -> a where
- toInterval :: i -> Interval a

- data SortOptions s = SortOptions {}
- data Aggregate
- data RedisKeyType
- type RedisInfo = Map String String
- sortDefaults :: SortOptions ByteString
- fromRInline :: (Monad m, BS s) => Reply s -> m s
- fromRBulk :: (Monad m, BS s) => Reply s -> m (Maybe s)
- fromRMulti :: (Monad m, BS s) => Reply s -> m (Maybe [Reply s])
- fromRMultiBulk :: (Monad m, BS s) => Reply s -> m (Maybe [Maybe s])
- fromRMultiBulk' :: (Monad m, BS s) => Reply s -> m [s]
- fromRInt :: (Monad m, BS s) => Reply s -> m Int
- fromROk :: (Monad m, BS s) => Reply s -> m ()
- noError :: (Monad m, BS s) => Reply s -> m ()
- parseMessage :: (Monad m, BS s) => Reply ByteString -> m (Message s)
- takeAll :: (Int, Int)
- localhost :: String
- defaultPort :: String
- connect :: WithRedis m => String -> String -> m ()
- disconnect :: WithRedis m => m ()
- isConnected :: WithRedis m => m Bool
- getServer :: WithRedis m => m (String, String)
- getDatabase :: WithRedis m => m Int
- renameCommand :: WithRedis m => ByteString -> ByteString -> m ()
- ping :: WithRedis m => m (Reply ())
- auth :: WithRedis m => String -> m (Reply ())
- echo :: (WithRedis m, BS s) => s -> m (Reply s)
- 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 () -> m (Reply s)
- watch :: (WithRedis m, BS s) => [s] -> m (Reply ())
- unwatch :: WithRedis m => m (Reply ())
- run_cas :: (MonadCatchIO m, WithRedis m, BS s1) => [s1] -> m a -> m a
- exists :: (WithRedis m, BS s) => s -> m (Reply Int)
- del :: (WithRedis m, BS s) => s -> m (Reply Int)
- del_ :: (WithRedis m, BS s) => [s] -> m (Reply Int)
- getType :: (WithRedis m, BS s1) => s1 -> m RedisKeyType
- 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)
- persist :: (WithRedis m, BS s) => s -> 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 => m RedisInfo
- set :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply ())
- setNx :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int)
- setEx :: (WithRedis m, BS s1, BS s2) => s1 -> Int -> s2 -> m (Reply ())
- 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)
- incrByFloat :: (WithRedis m, BS s) => s -> Double -> m (Reply Double)
- 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)
- getrange :: (WithRedis m, BS s1, BS s2) => s1 -> (Int, Int) -> m (Reply s2)
- setrange :: (WithRedis m, BS s1, BS s2) => s1 -> Int -> s2 -> m (Reply Int)
- getbit :: (WithRedis m, BS s) => s -> Int -> m (Reply Int)
- setbit :: (WithRedis m, BS s) => s -> Int -> Int -> m (Reply Int)
- strlen :: (WithRedis m, BS s) => s -> m (Reply Int)
- rpush :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int)
- rpush_ :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> m (Reply Int)
- lpush :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int)
- rpushx :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int)
- lpushx :: (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 (Maybe (s1, s2))
- brpop :: (WithRedis m, BS s1, BS s2) => [s1] -> Int -> m (Maybe (s1, s2))
- brpoplpush :: (WithRedis m, BS s1, BS s2, BS s3) => s1 -> s2 -> Int -> m (Maybe (Maybe s3))
- sadd :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> m (Reply Int)
- sadd_ :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> m (Reply Int)
- srem :: (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 s1, BS s2) => s1 -> s2 -> 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)
- 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)
- 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 -> Maybe (Int, Int) -> Bool -> m (Reply s2)
- zrevrangebyscore :: (WithRedis m, IsInterval i Double, BS s1, BS s2) => s1 -> i -> Maybe (Int, Int) -> 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)
- zunionStore :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> [Double] -> Aggregate -> m (Reply Int)
- zinterStore :: (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)
- 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)
- hincrByFloat :: (WithRedis m, BS s1, BS s2) => s1 -> s2 -> Double -> m (Reply Double)
- 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]
- psubscribe :: (WithRedis m, BS s1, BS s2) => [s1] -> m [Message s2]
- punsubscribe :: (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) => Int -> 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 ())

# Types ans Constructors

Redis connection descriptor

Redis reply variants

RTimeout | Timeout. Currently unused |

RParseError String | Error converting value from ByteString. It's a client-side error. |

ROk | "Ok" reply |

RPong | Reply for the ping command |

RQueued | Used inside multi-exec block |

RError String | Some kind of server-side error |

RInline s | Simple oneline reply |

RInt Int | Integer reply |

RBulk (Maybe s) | Multiline reply |

RMulti (Maybe [Reply s]) | Complex reply. It may consists of various type of replys |

MSubscribe s Int | subscribed |

MUnsubscribe s Int | unsubscribed |

MPSubscribe s Int | pattern subscribed |

MPUnsubscribe s Int | pattern unsubscribed |

MMessage s s | message recieved |

MPMessage s s s | message recieved by pattern |

Interval representation

Closed a a | closed interval [a, b] |

Open a a | open interval (a, b) |

LeftOpen a a | left-open interval (a, b] |

RightOpen a a | right-open interval [a, b) |

Show a => Show (Interval a) | |

IsInterval (Interval a) a | Trivial IsInterval instance |

class IsInterval i a | i -> a whereSource

Class for conversion value to `Interval`

Definied instances is:

- the Interval itself
- pair (a,b) for open interval
- two-member list [a, b] for closed interval (throws runtime error if the list length is different)

toInterval :: i -> Interval aSource

IsInterval [a] a | Two-element list [a, b] converted to closed interval. No static checking of list length performed. |

IsInterval (Interval a) a | Trivial IsInterval instance |

IsInterval (a, a) a | Pair (a, b) converted to open interval |

data SortOptions s Source

Options data type for the `sort`

command

sortDefaults :: SortOptions ByteStringSource

Default options for the `sort`

command

fromRInline :: (Monad m, BS s) => Reply s -> m sSource

Unwraps RInline reply.

Throws an exception when called with something different from RInline

fromRBulk :: (Monad m, BS s) => Reply s -> m (Maybe s)Source

Unwraps RBulk reply.

Throws an exception when called with something different from RBulk

fromRMulti :: (Monad m, BS s) => Reply s -> m (Maybe [Reply s])Source

Unwraps RMulti reply

Throws an exception when called with something different from RMulti

fromRMultiBulk :: (Monad m, BS s) => Reply s -> m (Maybe [Maybe s])Source

Unwraps RMulti reply filled with RBulk

Throws an exception when called with something different from RMulti

fromRMultiBulk' :: (Monad m, BS s) => Reply s -> m [s]Source

The same as fromRMultiBulk but with fromJust applied

fromRInt :: (Monad m, BS s) => Reply s -> m IntSource

Unwraps RInt reply

Throws an exception when called with something different from RInt

fromROk :: (Monad m, BS s) => Reply s -> m ()Source

Unwraps ROk reply

Throws an exception when called with something different from ROk

noError :: (Monad m, BS s) => Reply s -> m ()Source

Unwraps every non-error reply

Throws an exception when called with something different from RMulti

parseMessage :: (Monad m, BS s) => Reply ByteString -> m (Message s)Source

Parse Reply as a Message

Throws an exception on parse error

a (0, -1) range - takes all element from a list in lrange, zrange and so on

# Database connection

default Redis port

disconnect :: WithRedis m => m ()Source

isConnected :: WithRedis m => m BoolSource

getDatabase :: WithRedis m => m IntSource

renameCommand :: WithRedis m => ByteString -> ByteString -> m ()Source

# Redis commands

## Generic

run_cas :: (MonadCatchIO m, WithRedis m, BS s1) => [s1] -> m a -> m aSource

getType :: (WithRedis m, BS s1) => s1 -> m RedisKeyTypeSource

## Strings

## Lists

## Sets

## Sorted sets

zrangebyscore :: (WithRedis m, IsInterval i Double, BS s1, BS s2) => s1 -> i -> Maybe (Int, Int) -> Bool -> m (Reply s2)Source

zrevrangebyscore :: (WithRedis m, IsInterval i Double, BS s1, BS s2) => s1 -> i -> Maybe (Int, Int) -> Bool -> m (Reply s2)Source

zunion :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> [Double] -> Aggregate -> m (Reply Int)Source

Deprecated: ZUNION command was renamed to ZUNIONSTORE

zinter :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> [Double] -> Aggregate -> m (Reply Int)Source

Deprecated: ZINTER command was renamed to ZINTERSTORE

zunionStore :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> [Double] -> Aggregate -> m (Reply Int)Source

zinterStore :: (WithRedis m, BS s1, BS s2) => s1 -> [s2] -> [Double] -> Aggregate -> m (Reply Int)Source

## Hashes

## Sorting

## Publish/Subscribe

subscribed :: WithRedis m => m IntSource

## Persistent control

bgrewriteaof :: WithRedis m => m (Reply ())Source