1. Alvaro Videla
  2. redis-haskell

Wiki

Clone wiki

redis-haskell / Home

Redit Haskell

This are the Haskell bindings for Redis

Installation

$ hg clone http://bitbucket.org/videlalvaro/redis-haskell/
$ cd redis-haskell
$ runghc Setup configure -p
$ runghc Setup build
$ runghc Setup install

If the build step complains about missing profiling files then try configuring with the following command:

$ runghc Setup configure -p --disable-library-profiling

See the files RedisTest.hs and StringsExamples.hs for some examples on the usage

Implemented Commands

The following is the list of supported commands:

  get :: (Key k, Serializable s) => a -> k -> IO (Maybe s)
  set :: (Key k, Serializable s) => a -> k -> s -> IO (Bool)
  setnx :: (Key k, Serializable s) => a -> k -> s -> IO (Bool)
  getset :: (Key k, Serializable s) => a -> k -> s -> IO (Maybe s)
  mget :: (Key k, Serializable s) => a -> [k] -> IO (Maybe [Maybe s])
  incr :: (Key k) => a -> k -> IO (Maybe Int)
  decr :: (Key k) => a -> k -> IO (Maybe Int)
  incrby :: (Key k) => a -> k -> Int -> IO (Maybe Int)
  decrby :: (Key k) => a -> k -> Int -> IO (Maybe Int)
  exists :: (Key k) => a -> k -> IO (Bool)
  del :: (Key k) => a -> k -> IO (Bool)
  rtype :: (Key k) => a -> k -> IO (Maybe String)

  keys :: a -> String -> IO (Maybe [String])
  randomkey :: a -> IO (Maybe String)
  rename :: (Key k) => a -> k -> k -> IO (Bool)
  renamenx :: (Key k) => a -> k -> k -> IO (Bool)
  dbsize :: a -> IO (Maybe Int)
  expire :: (Key k) => a -> k -> Int -> IO (Bool)
  ttl    :: (Key k) => a -> k -> IO (Maybe Int)
         
  lrange :: (Key k, Serializable s) => a -> k -> Int -> Int -> IO (Maybe [Maybe s])
  lpush, rpush :: (Key k, Serializable s) => a -> k -> s -> IO (Bool)
  llen :: (Key k) => a -> k -> IO (Maybe Int)
  ltrim :: (Key k) => a -> k -> Int -> Int -> IO (Bool)
  lindex :: (Key k, Serializable s) => a -> k -> Int -> IO (Maybe s)
  lset :: (Key k, Serializable s) => a -> k -> Int -> s -> IO (Bool)
  lrem :: (Key k, Serializable s) => a -> k -> Int -> s -> IO (Maybe Int)
  lpop, rpop :: (Key k, Serializable s) => a -> k -> IO (Maybe s)
  
  sadd :: (Key k, Serializable s) => a -> k -> s -> IO (Bool)
  srem :: (Key k, Serializable s) => a -> k -> s -> IO (Bool)
  spop :: (Key k, Serializable s) => a -> k -> IO (Maybe s)
  smove :: (Key k, Serializable s) => a -> k -> k -> s -> IO (Bool)
  scard :: (Key k) => a -> k -> IO (Maybe Int)
  sismember :: (Key k, Serializable s) => a -> k -> s -> IO (Bool)
  sinter :: (Key k, Serializable s) => a -> [k] -> IO (Maybe [Maybe s])
  sunion :: (Key k, Serializable s) => a -> [k] -> IO (Maybe [Maybe s])
  sdiff :: (Key k, Serializable s) => a -> [k] -> IO (Maybe [Maybe s])
  sinterstore :: (Key k) => a -> k -> [k] -> IO (Maybe Int)
  sunionstore :: (Key k) => a -> k -> [k] -> IO (Maybe Int)
  sdiffstore :: (Key k) => a -> k -> [k] -> IO (Maybe Int)
  smembers :: (Key k, Serializable s) => a -> k -> IO (Maybe [Maybe s])
  srandmember :: (Key k, Serializable s) => a -> k -> IO (Maybe s)
  
  zadd :: (Key k, Serializable s) => a -> k -> Int -> s -> IO (Bool)
  zrem :: (Key k, Serializable s) => a -> k -> s -> IO (Bool)
  zrange, zrevrange, zrangebyscore :: (Key k, Serializable s) => a -> k -> Int -> Int -> IO (Maybe [Maybe s])
  zcard :: (Key k) => a -> k -> IO (Maybe Int)
  zscore :: (Key k, Serializable s) => a -> k -> s -> IO (Maybe String)
  
  select :: a -> Int -> IO (Bool)
  move :: (Key k) => a -> k -> Int -> IO (Bool)
  flushdb, flushall :: a -> IO (Bool)
  
  save, bgsave, shutdown :: a -> IO (Bool)
  lastsave :: a -> IO (Maybe Int)
  
  pong :: a -> IO (Maybe String)
  
  info :: a -> IO (Maybe [String])
  slaveoff :: a -> IO (Bool)
  slaveoff' :: a -> String -> Int -> IO (Bool)

STATUS

This code should be considered ALPHA, is the first release of the package, so handle with care. Also the the API may change, since I want to code it in a more haskelish way. I also want to try using the network-bytestring to see if the performance of the library get improved.

Since I'm Haskell beginner, any improvements or comments are welcomed.

Updated