All Projects → stefanwille → Crystal Redis

stefanwille / Crystal Redis

Licence: mit
Full featured Redis client for Crystal

Programming Languages

crystal
512 projects

Projects that are alternatives of or similar to Crystal Redis

Redisearch Py
RediSearch python client
Stars: ✭ 152 (-55.94%)
Mutual labels:  redis, redis-client
Cachingframework.redis
Distributed caching based on StackExchange.Redis and Redis. Includes support for tagging and is cluster-compatible.
Stars: ✭ 209 (-39.42%)
Mutual labels:  redis, redis-client
Go Rejson
Golang client for redislabs' ReJSON module with support for multilple redis clients (redigo, go-redis)
Stars: ✭ 164 (-52.46%)
Mutual labels:  redis, redis-client
Redis
Type-safe Redis client for Golang
Stars: ✭ 13,117 (+3702.03%)
Mutual labels:  redis, redis-client
Xredis
Redis C++ client, support the data slice storage, support redis cluster, thread-safe,multi-platform,connection pool, read/write separation.
Stars: ✭ 285 (-17.39%)
Mutual labels:  redis, redis-client
Camellia
camellia framework by netease-im. provider: 1) redis-client; 2) redis-proxy(redis-sentinel/redis-cluster); 3) hbase-client; 4) others
Stars: ✭ 146 (-57.68%)
Mutual labels:  redis, redis-client
Node Redis
A high-performance Node.js Redis client.
Stars: ✭ 14,573 (+4124.06%)
Mutual labels:  redis, redis-client
Csredis
.NET Core or .NET Framework 4.0+ client for Redis and Redis Sentinel (2.8) and Cluster. Includes both synchronous and asynchronous clients.
Stars: ✭ 1,714 (+396.81%)
Mutual labels:  redis, redis-client
Redisson
Redisson - Redis Java client with features of In-Memory Data Grid. Over 50 Redis based Java objects and services: Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Publish / Subscribe, Bloom filter, Spring Cache, Tomcat, Scheduler, JCache API, Hibernate, MyBatis, RPC, local cache ...
Stars: ✭ 17,972 (+5109.28%)
Mutual labels:  redis, redis-client
Redisdesktopmanager Windows
RedisDesktopManager-Windows 安装包和编译教程
Stars: ✭ 268 (-22.32%)
Mutual labels:  redis, redis-client
Redis Client App
A redis client application on mac, windows and linux.
Stars: ✭ 140 (-59.42%)
Mutual labels:  redis, redis-client
Redis Cpp17
redis-cpp17 is a cross platfrom compatible redis protocol with multithreaded c++17 client,server,proxy
Stars: ✭ 300 (-13.04%)
Mutual labels:  redis, redis-client
Redis web manager
Manage your Redis instance (see keys, memory used, connected client, etc...)
Stars: ✭ 139 (-59.71%)
Mutual labels:  redis, redis-client
Redisdesktopmanager Mac
Redis Desktop Manager Mac OSX DMG
Stars: ✭ 149 (-56.81%)
Mutual labels:  redis, redis-client
Aioredis Py
asyncio (PEP 3156) Redis support
Stars: ✭ 2,003 (+480.58%)
Mutual labels:  redis, redis-client
Redis3m
A C++ Redis client
Stars: ✭ 173 (-49.86%)
Mutual labels:  redis, redis-client
Redli
Redli - A humane alternative to the Redis-cli and TLS
Stars: ✭ 126 (-63.48%)
Mutual labels:  redis, redis-client
Kangaroo
SQL client and admin tool for popular databases
Stars: ✭ 127 (-63.19%)
Mutual labels:  redis, redis-client
Pottery
Redis for humans. 🌎🌍🌏
Stars: ✭ 204 (-40.87%)
Mutual labels:  redis, redis-client
Redisclient
Boost.asio based Redis-client library.
Stars: ✭ 289 (-16.23%)
Mutual labels:  redis, redis-client

Redis Client for Crystal

Build Status PRs Welcome

A Redis client for the Crystal programming language.

Features

  • Performance (> 680,000 commands per second using pipeline on a MacBook Air with a single client thread)
  • Pipelining
  • Transactions
  • LUA Scripting
  • All string commands
  • All hash commands
  • All list commands
  • All set commands
  • All hyperloglog commands
  • All commands for bit operations
  • All sorted set commands
  • All geo commands
  • Publish/subscribe

Installation

Add it to your shard.yml:

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

and then install the library into your project:

$ shards install

Installation on MacOS X

On MacOS X you may get this error:

ld: library not found for -lssl (this usually means you need to install the development package for libssl)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
...

Or 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

Note: Please write me if you know a better way!

Required Crystal Version

This library needs Crystal version >= 0.34.0

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")

Connection Pooling

Since version 2.0.0, a connection pool is built in. It is used implicitly through Redis::PooledClient:

redis = Redis::PooledClient.new
10.times do |i|
  spawn do
    redis.set("foo#{i}", "bar")
    redis.get("foo#{i}") # => "bar"
  end
end

This redis instance can be shared across fibers, and accepts the same Redis commands as the Redis class. It automatically allocates and frees connections from/to the pool, per command.

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:

  • Crystal: With this library I get > 680,000 commands per second using pipeline on a MacBook Air with a single client thread.

  • C: The equivalent program written in C with Hiredis gets me 340,000 commands per second.

  • Ruby: Ruby 2.2.1 with the redis-rb and Hiredis driver handles 150,000 commands per second.

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

Status

I have exercised every API method in the spec and built some example programs. Some people report production usage.

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. In Homebrew's default redis.config the Unix domain socket option is disabled. To enable, edit /usr/local/etc/redis.conf or whatever your redis.conf is and uncomment this line:

# unixsocket /tmp/redis.sock

so that it reads

unixsocket /tmp/redis.sock

Then you can run the specs via

$ crystal spec

See more information.

WARNING

Running the spec will delete database number 0!

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].