redis-0.1: A driver for Redis key-value database

Database.Redis.Monad

Contents

Description

Monadic wrapper for Database.Redis.Redis

Synopsis

Types ans Constructors

class MonadIO m => WithRedis m whereSource

Instances

data Redis Source

Redis connection descriptor

Constructors

Redis 

Fields

server :: (String, String)

hostname and port pair

handle :: Handle

real network connection

Instances

data Reply Source

Redis reply variants

Constructors

RTimeout

Timeout. Currently unused

ROk

"Ok" reply

RPong

Reply for the ping command

RQueued

Used inside multi-exec block

RError String

Some kind of server-side error

RInline String

Simple oneline reply

RInt Int

Integer reply

RBulk (Maybe String)

Multiline reply

RMulti (Maybe [Reply])

Complex reply. It may consists of various type of replys

Instances

data Interval a Source

Interval representation

Constructors

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)

Instances

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)

Methods

toInterval :: i -> Interval aSource

Instances

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 Source

Options data type for the sort command

Constructors

SortOptions 

Fields

desc :: Bool

sort with descending order

limit :: (Int, Int)

return (from, to) elements

alpha :: Bool

sort alphabetically

sort_by :: String

sort by value from this key

get_obj :: [String]

return this keys values

store :: String

store result to this key

sortDefaults :: SortOptionsSource

Default options for the sort command

fromRInline :: Monad m => Reply -> m StringSource

Unwraps RInline reply.

Throws an exception when called with something different from RInline

fromRBulk :: Monad m => Reply -> m (Maybe String)Source

Unwraps RBulk reply.

Throws an exception when called with something different from RBulk

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

Unwraps RMulti reply

Throws an exception when called with something different from RMulti

fromRMultiBulk :: Monad m => Reply -> m (Maybe [Maybe String])Source

Unwraps RMulti reply filled with RBulk

Throws an exception when called with something different from RMulti

fromRInt :: Monad m => Reply -> m IntSource

Unwraps RInt reply

Throws an exception when called with something different from RInt

fromROk :: Monad m => Reply -> m ()Source

Unwraps ROk reply

Throws an exception when called with something different from ROk

noError :: Monad m => Reply -> m ()Source

Unwraps every non-error reply

Throws an exception when called with something different from RMulti

takeAll :: (Int, Int)Source

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

Database connection

localhost :: StringSource

just a localhost

defaultPort :: StringSource

default Redis port

Redis commands

Generic

Strings

Lists

Sets

Sorted sets

zrange :: WithRedis m => String -> (Int, Int) -> Bool -> m ReplySource

Sorting

Persistent control