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

Database.Redis.Redis

Contents

Description

Main Redis API and protocol implementation

Synopsis

Types ans Constructors

data Redis Source

Redis connection descriptor

Instances

data BS s => Reply s 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 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

Instances

(Eq s, BS s) => Eq (Reply s) 
BS s => Show (Reply s) 

data BS s => Message s Source

Constructors

MSubscribe s Int 
MUnsubscribe s Int 
MMessage s s 

Instances

(Show s, BS s) => Show (Message s) 

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 BS s => SortOptions s 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 :: s

sort by value from this key

get_obj :: [s]

return this keys values

store :: s

store result to this key

data Aggregate Source

Constructors

SUM 
MIN 
MAX 

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

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

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

connect :: String -> String -> IO RedisSource

Conects to Redis server and returns connection descriptor

disconnect :: Redis -> IO ()Source

Close connection

isConnected :: Redis -> IO BoolSource

Returns True when connection handler is opened

Redis commands

Generic

ping :: Redis -> IO (Reply ())Source

ping - pong

RPong returned if no errors happends

authSource

Arguments

:: BS s 
=> Redis 
-> s

password

-> IO (Reply ()) 

Password authentication

ROk returned

quit :: Redis -> IO ()Source

Quit and close connection

shutdown :: Redis -> IO ()Source

Stop all the clients, save the DB, then quit the server

multi :: Redis -> IO (Reply ())Source

Begin the multi-exec block

ROk returned

exec :: BS s => Redis -> IO (Reply s)Source

Execute queued commands

RMulti returned - replys for all executed commands

discard :: Redis -> IO (Reply ())Source

Discard queued commands without execution

ROk returned

run_multiSource

Arguments

:: BS s 
=> Redis 
-> [IO (Reply ())]

IO actions to run

-> IO (Reply s) 

Run commands within multi-exec block

RMulti returned - replys for all executed commands

existsSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> IO (Reply Int) 

Test if the key exists

(RInt 1) returned if the key exists and (RInt 0) otherwise

delSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> IO (Reply Int) 

Remove the key

(RInt 0) returned if no keys were removed or (RInt n) with removed keys count

getTypeSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> IO (Reply s2) 

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

keysSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target keys pattern

-> IO (Reply s2) 

Returns all the keys matching the glob-style pattern

RMulti filled with RBulk returned

randomKey :: BS s => Redis -> IO (Reply s)Source

Return random key name

RInline returned

renameSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

source key

-> s2

destination key

-> IO (Reply ()) 

Rename the key. If key with that name exists it'll be overwritten.

ROk returned

renameNxSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

source key

-> s2

destination key

-> IO (Reply Int) 

Rename the key if no keys with destination name exists.

(RInt 1) returned if key was renamed and (RInt 0) otherwise

dbsize :: Redis -> IO (Reply Int)Source

Get the number of keys in the currently selected database

RInt returned

expireSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> Int

timeout in seconds

-> 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

expireAtSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> Int

timeout in seconds

-> 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

ttlSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> IO (Reply Int) 

Return the remining time to live of the key or -1 if key has no associated timeout

RInt returned

selectSource

Arguments

:: Redis 
-> Int

database number

-> IO (Reply ()) 

Select the DB with the specified zero-based numeric index

ROk returned

moveSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> Int

destination database number

-> IO (Reply Int) 

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

flushDb :: Redis -> IO (Reply ())Source

Delete all the keys of the currently selected DB

ROk returned

flushAll :: Redis -> IO (Reply ())Source

Delete all the keys of all the existing databases

ROk returned

info :: BS s => Redis -> IO (Reply s)Source

Returns different information and statistics about the server

for more information see http://code.google.com/p/redis/wiki/InfoCommand

RBulk returned

Strings

setSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> s2

value

-> IO (Reply ()) 

Set the string value as value of the key

ROk returned

setNxSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> s2

value

-> IO (Reply Int) 

Set the key value if key does not exists

(RInt 1) returned if key was set and (RInt 0) otherwise

mSetSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> [(s1, s2)]

(key, value) pairs

-> IO (Reply ()) 

Atomically set multiple keys

ROk returned

mSetNxSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> [(s1, s2)]

(key, value) pairs

-> IO (Reply Int) 

Atomically set multiple keys if none of them exists.

(RInt 1) returned if all keys was set and (RInt 0) otherwise

getSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> IO (Reply s2) 

Get the value of the specified key.

RBulk returned

getSetSource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

target key

-> s2

value

-> IO (Reply s3) 

Atomically set this value and return the old value

RBulk returned

mGetSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> [s1]

target keys

-> IO (Reply s2) 

Get the values of all specified keys

RMulti filled with RBulk replys returned

incrSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> IO (Reply Int) 

Increment the key value by one

RInt returned with new key value

incrBySource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> Int

increment

-> IO (Reply Int) 

Increment the key value by N

RInt returned with new key value

decrSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> IO (Reply Int) 

Decrement the key value by one

RInt returned with new key value

decrBySource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> Int

decrement

-> IO (Reply Int) 

Decrement the key value by N

RInt returned with new key value

appendSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> s2

value

-> IO (Reply Int) 

Append string to the string-typed key

RInt returned - the length of resulting string

substr :: (BS s1, BS s2) => Redis -> s1 -> (Int, Int) -> IO (Reply s2)Source

Get a substring. Indexes are zero-based.

RBulk returned

Lists

rpushSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> s2

value

-> IO (Reply Int) 

Add string value to the head of the list-type key. New list length returned

RInt returned

lpushSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> s2

value

-> IO (Reply Int) 

Add string value to the tail of the list-type key. New list length returned

RInt returned

llenSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> 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

lrangeSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

traget key

-> (Int, Int)

(from, to) pair

-> IO (Reply s2) 

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

ltrimSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> (Int, Int)

(from, to) pair

-> IO (Reply ()) 

Trim list so that it will contain only the specified range of elements.

ROk returned

lindexSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> Int

index

-> IO (Reply s2) 

Return the specified element of the list by its index

RBulk returned

lsetSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> Int

index

-> s2

new value

-> 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

lremSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> Int

occurrences

-> s2

value

-> IO (Reply Int) 

Remove the first count occurrences of the value element from the list

RInt returned - the number of elements removed

lpopSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> IO (Reply s2) 

Atomically return and remove the first element of the list

RBulk returned

rpopSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> IO (Reply s2) 

Atomically return and remove the last element of the list

RBulk returned

rpoplpushSource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

source key

-> s2

destination key

-> IO (Reply s3) 

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

blpopSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> [s1]

keys list

-> Int

timeout

-> IO (Reply s2) 

Blocking lpop

For more information see http://code.google.com/p/redis/wiki/BlpopCommand

RMulti returned filled with key name and popped value

brpopSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> [s1]

keys list

-> Int

timeout

-> 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

Sets

saddSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> s2

value

-> IO (Reply Int) 

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

sremSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> s2

value

-> 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

spopSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> IO (Reply s2) 

Remove a random element from a Set returning it as return value

RBulk returned

smoveSource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

source key

-> s2

destination key

-> s3

value

-> IO (Reply Int) 

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

scardSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> IO (Reply Int) 

Return the number of elements of the set. If key doesn't exists 0 returned.

RInt returned

sismemberSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> 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

smembersSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> IO (Reply s2) 

Return all the members (elements) of the set

RMulti filled with RBulk returned

srandmemberSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> IO (Reply s2) 

Return a random element from a set

RBulk returned

sinterSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> [s1]

keys list

-> IO (Reply s2) 

Return the members of a set resulting from the intersection of all the specifided sets

RMulti filled with RBulk returned

sinterStoreSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

where to store resulting set

-> [s2]

sets list

-> IO (Reply ()) 

The same as sinter but instead of being returned the resulting set is stored

ROk returned

sunionSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> [s1]

keys list

-> IO (Reply s2) 

Return the members of a set resulting from the union of all the specifided sets

RMulti filled with RBulk returned

sunionStoreSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

where to store resulting set

-> [s2]

sets list

-> IO (Reply ()) 

The same as sunion but instead of being returned the resulting set is stored

ROk returned

sdiffSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> [s1]

keys list

-> IO (Reply s2) 

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

sdiffStoreSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

where to store resulting set

-> [s2]

sets list

-> IO (Reply ()) 

The same as sdiff but instead of being returned the resulting set is stored

ROk returned

Sorted sets

zaddSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> Double

score

-> s2

value

-> IO (Reply Int) 

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

zremSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> s2

value

-> 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

zincrBySource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

target key

-> Double

increment

-> s2

value

-> IO (Reply s3) 

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

zrangeSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> (Int, Int)

(from, to) pair

-> Bool

withscores option

-> IO (Reply s2) 

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

zrevrangeSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> (Int, Int)

(from, to) pair

-> Bool

withscores option

-> 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

zrangebyscoreSource

Arguments

:: (IsInterval i Double, BS s1, BS s2) 
=> Redis 
-> s1

target key

-> i

scores interval

-> Bool

withscores option

-> 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

zcountSource

Arguments

:: (IsInterval i Double, BS s) 
=> Redis 
-> s

target key

-> i

scores interval

-> IO (Reply Int) 

Count a number of elements of the sorted set with a score that lays within a given interval

RInt returned

zremrangebyscoreSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> (Double, Double)

(from, to) pair. zremrangebyscore currently doesn't supports open intervals

-> 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

zcardSource

Arguments

:: BS s 
=> Redis 
-> s

target key

-> IO (Reply Int) 

Return the sorted set cardinality (number of elements)

RInt returned

zscoreSource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

target key

-> s2

value

-> IO (Reply s3) 

Return the score of the specified element of the sorted set

RBulk returned

zrank :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int)Source

Returns sorted set element sequence number counting from zero

RInt returned

zrevrank :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int)Source

Returns sorted set element sequence number for reversed sort order

RInt returned

zremrangebyrank :: BS s => Redis -> s -> (Int, Int) -> IO (Reply Int)Source

Remove elements from the sorted set with rank lays within a given interval.

RInt returned - the number of elements removed

zunionSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

destination key

-> [s2]

sources keys

-> [Double]

weights

-> Aggregate

aggregate

-> 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.

zinterSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

destination key

-> [s2]

sources keys

-> [Double]

weights

-> Aggregate

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.

Hashes

hsetSource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

target key

-> s2

field name

-> s3

value

-> 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

hgetSource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

key

-> s2

field name

-> IO (Reply s3) 

Return value associated with specified field from hash

RBulk returned

hdelSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

key

-> s2

field name

-> IO (Reply Int) 

Remove field from a hash

(RInt 1) returned if field was removed and (RInt 0) otherwise

hmsetSource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

target key

-> [(s2, s3)]

(field, value) pairs

-> IO (Reply ()) 

Atomically sets multiple fields within a hash-typed key

ROk returned

hmgetSource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

target key

-> [s2]

field names

-> IO (Reply s3) 

Get the values of all specified fields from the hash-typed key

RMulti filled with RBulk replys returned

hincrbySource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

target key

-> s2

field name

-> Int

increment

-> IO (Reply Int) 

Increment the field value within a hash by N

RInt returned with new key value

hexistsSource

Arguments

:: (BS s1, BS s2) 
=> Redis 
-> s1

key

-> s2

field name

-> IO (Reply Int) 

Test if hash contains the specified field

(RInt 1) returned if fiels exists and (RInt 0) otherwise

hlen :: BS s => Redis -> s -> IO (Reply Int)Source

Return the number of fields contained in the specified hash

RInt returned

hkeys :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2)Source

Return all the field names the hash holding

RMulti field with RBulk returned

hvals :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2)Source

Return all the associated values the hash holding

RMulti field with RBulk returned

hgetall :: (BS s1, BS s2) => Redis -> s1 -> IO (Reply s2)Source

Return all the field names and associated values the hash holding in form of [field1, value1, field2, value2...]

RMulti field with RBulk returned

Sorting

sortSource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

target key

-> SortOptions s2

options

-> IO (Reply s3) 

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

listRelatedSource

Arguments

:: (BS s1, BS s2, BS s3) 
=> Redis 
-> s1

related key

-> s2

index key

-> (Int, Int)

range

-> IO (Reply s3) 

Shortcut for the sort with some get_obj and constant sort_by options

RMulti filled with RBulk returned

Publish/Subscribe

subscribed :: Redis -> IO IntSource

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

subscribe :: (BS s1, BS s2) => Redis -> [s1] -> IO [Message s2]Source

Subscribe to channels

list of Message with subscribtion information returned

unsubscribe :: (BS s1, BS s2) => Redis -> [s1] -> IO [Message s2]Source

Unsubscribe from channels

list of Message with subscribtion information returned

publish :: (BS s1, BS s2) => Redis -> s1 -> s2 -> IO (Reply Int)Source

Publish message to target channel

RInt returned - a number of clients

listen :: BS s => Redis -> IO (Maybe (Message s))Source

Wait for a messages.

Important! Client will be blocken untill some message recieved!

Message returned

Persistent control

save :: Redis -> IO (Reply ())Source

Save the whole dataset on disk

ROk returned

bgsave :: Redis -> IO (Reply ())Source

Save the DB in background

ROk returned

lastsave :: Redis -> IO (Reply Int)Source

Return the UNIX TIME of the last DB save executed with success

RInt returned

bgrewriteaof :: Redis -> IO (Reply ())Source

Rewrites the Append Only File in background

ROk returned