Redis Client for Crystal

Build Status PRs Welcome

A Redis client for the Crystal programming language.

Features

Installation

Add it to your shard.yml:

dependencies:
  redis:
    github: stefanwille/crystal-redis
    version: ~> 1.10.1

and then install the library into your project:

$ crystal deps

Installation on MacOS X

On MacOS X you may get this warning:

Package libssl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libssl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libssl' found
Package libcrypto was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcrypto.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcrypto' found

The problem is that Crystal can't find openssl, because it is not installed by default on MacOS X.

The fix:

  1. Install openssl via Homebrew:
$ brew install openssl
  1. Set the environment variable PKG_CONFIG_PATH:
$ export PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig

Required Crystal Version

This library needs Crystal version >= 0.24.2

I haven't tested older Crystal versions.

Usage

Require the package:

  require "redis"

then

  redis = Redis.new

Then you can call Redis commands on the redis object:

  redis.set("foo", "bar")
  redis.get("foo")

Examples

To get started, see the examples:

Documentation

Performance

I have benchmarked Crystal-Redis against several other client libraries in various programming languages in this blog article.

Here are some results:

Read more results for Go, Java, Node.js.

Status

I have exercised every API method in the spec and built some example programs. There is no production use yet.

I took great care to make this library very usable with respect to API, reliability and documentation.

Development

This project requires a locally running redis server running on port 6379 and with a unix socket located at /tmp/redis.sock. Then you can the specs via

$ crystal spec

See more information.

Questions, Bugs & Support

If you have questions or need help, please open a ticket in the GitHub issue tracker. This way others can benefit from the discussion.