Skip to content

glejeune/exredis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

exredis Build Status

Redis client for Elixir


Installation

Add this to the dependencies:

# edge
{ :exredis, "0.0.2", [ github: "artemeff/exredis" ] }

# stable
{ :exredis, "0.0.1", [ github: "artemeff/exredis", tag: "0.0.1" ] }

Usage

As mixin

defmodule Pi do
  use Exredis

  def get, do: start |> query ["GET", "Pi"]
  def set, do: start |> query ["SET", "Pi", "3.14"]
end

Pi.set
# => "OK"

Pi.get
# => "3.14"

Connect to the Redis server

client = Exredis.start

Set & Get

# set
Exredis.query(client, ["SET", "FOO", "BAR"])

# get
Exredis.query(client, ["GET", "FOO"])
# => "BAR"

Mset & Mget

# mset
Exredis.query(client, ["MSET" | ["key1", "value1", "key2", "value2", "key3", "value3"]])

# mget
Exredis.query(client, ["MGET" | ["key1", "key2", "key3"]])
# => ["value1","value2","value3"]

Transactions

# start
Exredis.query(client, ["MULTI"])

# exec
Exredis.query(client, ["SET", "foo", "bar"])
Exredis.query(client, ["SET", "bar", "baz"])

# commit
Exredis.query(client, ["EXEC"])

Pipelining

Exredis.query_pipe(client, [["SET", :a, "1"], ["LPUSH", :b, "3"], ["LPUSH", :b, "2"]])

Pub/sub (maybe won't work)

Exredis.subscribe(client, "foo")
Exredis.publish(client, "foo", "bar")

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

Redis client for Elixir

Resources

License

Stars

Watchers

Forks

Packages

No packages published