A light-weight low-level Redis client for Crystal šŸŒ¶
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
spec initial release Jan 27, 2019
src initial release Jan 27, 2019
.editorconfig initial release Jan 27, 2019
.gitignore initial release Jan 27, 2019
.travis.yml initial release Jan 27, 2019
LICENSE initial release Jan 27, 2019
README.md chore (README): add patronage motivation Feb 18, 2019
shard.yml initial release Jan 27, 2019



Built with Crystal Build status API Docs Releases Awesome vladfaust.com Patrons count Gitter chat

A light-weight Redis client for Crystal.


Thanks to all my patrons, I can build and support beautiful Open Source Software! šŸ™

Alexander Maslov, Lauri Jutila

You can become a patron too in exchange of prioritized support and other perks

Become Patron


MiniRedis is a light-weight low-level alternative to existing Redis client implementations.

In comparison with crystal-redis, MiniRedis is slightly faster, has first-class support for raw bytes and doesn't need to be updated with every Redis release. On the other hand, MiniRedis doesn't have commands API (i.e. instead of redis.ping you should write redis.command("PING")). However, such a low-level interface terminates the dependency on the third-party client maintainer (i.e. me), which makes it a perfect fit to use within a shard.


  1. Add the dependency to your shard.yml:
    github: vladfaust/mini_redis
    version: ~> 0.1.0
  1. Run shards install


require "mini_redis"

redis = MiniRedis.new

# Inline (i.e. one-line) commands are usually faster, because they don't need marshalling
pp redis.command("PING").raw.as(String) # => "PONG"

# MiniRedis responses wrap `Int64 | String | Bytes | Nil | Array(Value)` values, which are
# properly mapped to `integer`, `simple string`, `bulk string`, `nil` and `array` Redis values
pp redis.command("SET foo bar").raw.as(String) # => "OK"
bytes = redis.command("GET foo").raw.as(Bytes)
pp String.new(bytes) # => "bar"

# It is possible to declare commands as enumerables (or pass as many arguments),
# so they are going to be marshalled according to the Redis protocol.
# It is particulary useful for commands with binary payloads
redis.command({"set", "foo", "bar".to_slice})
redis.command("set", "foo", "bar".to_slice)

# It is possible to split sending and receiving the response
redis.send("SET foo bar")

# Pipelining
response = redis.pipeline do |pipe|
  pipe.send("SET foo bar")

pp typeof(response) # => Array(MiniRedis::Value)

# Transactions
response = redis.transaction do |tx|
  tx.send("SET foo bar")

pp typeof(response) # => MiniRedis::Value


env REDIS_URL=redis://localhost:6379 crystal spec and you're good to go.


  1. Fork it (https://github.com/vladfaust/mini_redis/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'feat: new feature') using angular-style commits
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request