Git Product home page Git Product logo

redis's Introduction

Redis Build Status Hex.pm


Redis commands for Elixir. If you are looking for exredis, please check out exredis branch.



Installation

Add this to the dependencies:

{:redis, "~> 0.1"}

Usage

Redis commands have a few simple types: enums, commands and primitive. Types can be required and optional, multiple and variadic, can be composite.

Situation with required and optional types is simple: required types are just arguments in function and optional values passed with the last argument โ€” opts. opts is just a list, opts described in typespecs for each command.

Multiple arguments are arguments that contain one or more values. Multiple arguments can be optional.

Enum types in Redis is just a enumerable (usually), take a look at xx | nx enum:

iex> Redis.set("key", "value", [:xx])
["SET", [" ", "key"], [" ", "value"], [], [" ", "XX"]]

iex> Redis.set("key", "value", [:nx])
["SET", [" ", "key"], [" ", "value"], [], [" ", "NX"]]

Commands are prefixed types, commands can wrap primitive types, enums and composite types:

# command with enum inside
iex> Redis.client_kill(type: :master)
["CLIENT KILL", [], [], [" ", ["TYPE", " ", "master"]], [], []]

# command with primitive type inside
iex> Redis.client_kill(id: "identity")
["CLIENT KILL", [], [" ", ["ID", " ", "identity"]], [], [], []]

# command with composite type inside, inner type of get is: {String.t, integer()}
iex> Redis.bitfield("key", get: {"type", "offset"})
["BITFIELD", [" ", "key"], [" ", ["GET", " ", ["type", " ", "offset"]]], [], [], []]

You can see the usage for every Redis command in IEx:

iex> h Redis.set

  def set(key, value, opts \\ [])

  @spec set(
          key :: key(),
          value :: String.t(),
          opts :: [
            {:expiration, {:ex, :integer} | {:px, :integer}}
            | (:nx | :xx)
            | {:condition, :nx | :xx}
          ]
        ) :: iolist()

since: 1.0.0

Set the string value of a key

Group: string.

Or head to the documentation on hexdocs.


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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.