Giter VIP home page Giter VIP logo

comredis's Introduction

Build Status

Comredis

Comredis is your comrade for Redis command generation in Elixir. It helps you generate correct commands with the right arity. You can then use your favorite client to push them to Redis.

It parses the Redis commands documentation and generates functions in compile-time. All functions are defined in the Comredis module.

Installation

Add the :comredis dependency to your mix.exs file:

defp dependencies do
  [{:comredis, ">= 0.0.0"}]
end

Then run $ mix deps.get to install it.

Examples

Comredis.client_list
#=> ["CLIENT", "LIST"]

Comredis.get("k")
#=> ["GET", "k"]

Comredis.mget(["k1", "k2"])
#=> ["MGET", "k1", "k2"]

Comredis.set("k", "v")
#=> ["SET", "k", "v"]

# Using SET with expire time. It allows only the options the command accepts
Comredis.set("k", "v", ex: 10)
#=> ["SET", "k", "v", "EX", 10]

You also get nice documentation for each command directly from the Redis' documentation. You can even check it out right off your IEx session.

h Comredis.get
                                   def get(key)

Get the value of a key

Group: string

Available since Redis version 1.0.0.

Time complexity: O(1)

Arguments:

  • key

TODO

  • Tested against clients(Redix and Exredis)
  • Increase the amount of examples for the generated functions with doctests
  • Property based testing to guarantee it will not crash the application
  • Generate typespecs
  • Type check the command arguments

comredis's People

Contributors

iurifq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

comredis's Issues

Commands JSON not included in Hex package.

The commands.json file is not included in the Hex package generated (per v1.0.0) thus causing compilation to fail when adding comredis as a dependency in other projects.

Using it directly from GitHub works:

  defp deps do
    [
      # {:comredis, ">= 1.0.0"},  # Goes BOOM! Won't compile.
      {:comredis, git: "https://github.com/iurifq/comredis.git"},  # OK
    ]
  end

Console output:

$ mix deps.get ; iex -S mix
Running dependency resolution
All dependencies up to date
Erlang/OTP 18 [erts-7.3] [source-d2a6d81] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]

==> comredis
Compiled lib/comredis/command.ex
Compiled lib/comredis/command/doc_test.ex
Compiled lib/comredis/command/argument.ex
Compiled lib/comredis/command/file_reader.ex
Compiled lib/comredis/command/generator.ex

== Compilation error on file lib/comredis.ex ==
** (File.Error) could not read file commands.json: no such file or directory
    (elixir) lib/file.ex:244: File.read!/1
    lib/comredis/command/file_reader.ex:48: Comredis.Command.FileReader.from_file/0
    lib/comredis/command/file_reader.ex:16: Comredis.Command.FileReader.load/0
    expanding macro: Comredis.Command.Generator.__using__/1
    lib/comredis.ex:11: Comredis (module)
    (elixir) expanding macro: Kernel.use/1
    lib/comredis.ex:11: Comredis (module)

could not compile dependency :comredis, "mix compile" failed. You can recompile this dependency with "mix deps.compile comredis", update it with "mix deps.update comredis" or clean it with "mix deps.clean comredis"

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.