All Projects β†’ whatyouhide β†’ Redix

whatyouhide / Redix

Licence: mit
Fast, pipelined, resilient Redis driver for Elixir. πŸ›

Programming Languages

elixir
2628 projects

Projects that are alternatives of or similar to Redix

Aioredis Py
asyncio (PEP 3156) Redis support
Stars: ✭ 2,003 (+145.47%)
Mutual labels:  redis, redis-client, redis-sentinel
Ioredis
πŸš€ A robust, performance-focused, and full-featured Redis client for Node.js.
Stars: ✭ 9,754 (+1095.34%)
Mutual labels:  redis, redis-client, redis-sentinel
Lettuce Core
Advanced Java Redis client for thread-safe sync, async, and reactive usage. Supports Cluster, Sentinel, Pipelining, and codecs.
Stars: ✭ 4,319 (+429.29%)
Mutual labels:  redis, redis-client, redis-sentinel
Camellia
camellia framework by netease-im. provider: 1) redis-client; 2) redis-proxy(redis-sentinel/redis-cluster); 3) hbase-client; 4) others
Stars: ✭ 146 (-82.11%)
Mutual labels:  redis, redis-client, redis-sentinel
Crystal Redis
Full featured Redis client for Crystal
Stars: ✭ 345 (-57.72%)
Mutual labels:  redis, redis-client
Fastoredis
FastoRedis is a crossplatform Redis GUI management tool.
Stars: ✭ 316 (-61.27%)
Mutual labels:  redis, redis-client
Redis
Redis commands for Elixir
Stars: ✭ 357 (-56.25%)
Mutual labels:  redis, redis-client
Redis Plus Plus
Redis client written in C++
Stars: ✭ 428 (-47.55%)
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 (+2102.45%)
Mutual labels:  redis, redis-client
Ledge
An RFC compliant and ESI capable HTTP cache for Nginx / OpenResty, backed by Redis
Stars: ✭ 412 (-49.51%)
Mutual labels:  redis, redis-sentinel
Redis
Vapor provider for RediStack
Stars: ✭ 434 (-46.81%)
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 (-63.24%)
Mutual labels:  redis, redis-client
Redisclient
Boost.asio based Redis-client library.
Stars: ✭ 289 (-64.58%)
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 (-65.07%)
Mutual labels:  redis, redis-client
Quick redis blog
QuickRedis is a free forever Redis Desktop manager. It supports direct connection, sentinel, and cluster mode, supports multiple languages, supports hundreds of millions of keys, and has an amazing UI. Supports both Windows, Mac OS X and Linux platform.
Stars: ✭ 594 (-27.21%)
Mutual labels:  redis, redis-client
Stackexchange.redis.extensions
Stars: ✭ 419 (-48.65%)
Mutual labels:  redis, redis-client
Stackexchange.redis
General purpose redis client
Stars: ✭ 4,986 (+511.03%)
Mutual labels:  redis, redis-client
Redis Operator
Redis Operator creates/configures/manages high availability redis with sentinel automatic failover atop Kubernetes.
Stars: ✭ 658 (-19.36%)
Mutual labels:  redis, redis-client
Redis Tui
A Redis Text-based UI client in CLI
Stars: ✭ 757 (-7.23%)
Mutual labels:  redis, redis-client
salad
Asynchronous Scala Redis Client supporting Sentinel and Redis Cluster
Stars: ✭ 14 (-98.28%)
Mutual labels:  redis-sentinel, redis-client

Redix

Coverage Status Hex.pm

Fast, pipelined, resilient Redis client for Elixir.

Cover image

Redix is a Redis client written in pure Elixir with focus on speed, correctness, and resiliency (that is, being able to automatically reconnect to Redis in case of network errors).

This README refers to the master branch of Redix, not the latest released version on Hex. Make sure to check the documentation for the version you're using.

Features

  • Idiomatic interface for sending commands to Redis
  • Pipelining
  • Resiliency (automatic reconnections)
  • Pub/Sub
  • SSL
  • Redis Sentinel

Installation

Add the :redix dependency to your mix.exs file. If you plan on connecting to a Redis server over SSL you may want to add the optional :castore dependency as well:

defp deps() do
  [
    {:redix, ">= 0.0.0"},
    {:castore, ">= 0.0.0"}
  ]
end

Then, run mix deps.get in your shell to fetch the new dependencies.

Usage

Redix is simple: it doesn't wrap Redis commands with Elixir functions. It only provides functions to send any Redis command to the Redis server. A Redis command is expressed as a list of strings making up the command and its arguments.

Connections are started via start_link/0,1,2:

{:ok, conn} = Redix.start_link(host: "example.com", port: 5000)
{:ok, conn} = Redix.start_link("redis://localhost:6379/3", name: :redix)

Commands can be sent using Redix.command/2,3:

Redix.command(conn, ["SET", "mykey", "foo"])
#=> {:ok, "OK"}
Redix.command(conn, ["GET", "mykey"])
#=> {:ok, "foo"}

Pipelines are just lists of commands sent all at once to Redis for which Redis replies with a list of responses. They can be used in Redix via Redix.pipeline/2,3:

Redix.pipeline(conn, [["INCR", "foo"], ["INCR", "foo"], ["INCRBY", "foo", "2"]])
#=> {:ok, [1, 2, 4]}

Redix.command/2,3 and Redix.pipeline/2,3 always return {:ok, result} or {:error, reason}. If you want to access the result directly and raise in case there's an error, bang! variants are provided:

Redix.command!(conn, ["PING"])
#=> "PONG"

Redix.pipeline!(conn, [["SET", "mykey", "foo"], ["GET", "mykey"]])
#=> ["OK", "foo"]

Resiliency

Redix is resilient against network errors. For example, if the connection to Redis drops, Redix will automatically try to reconnect periodically at a given "backoff" interval. Look at the documentation for the Redix module and at the "Reconnections" page in the documentation for more information on the available options and on the exact reconnection behaviour.

Redis Sentinel

Redix supports Redis Sentinel out of the box. You can specify a list of sentinels to connect to when starting a Redix (or Redix.PubSub) connection. Every time that connection will need to connect to a Redis server (the first time or after a disconnection), it will try to connect to one of the sentinels in order to ask that sentinel for the current primary or a replica.

sentinels = ["redis://sent1.example.com:26379", "redis://sent2.example.com:26379"]
{:ok, primary} = Redix.start_link(sentinel: [sentinels: sentinels, group: "main"])
Terminology

Redix doesn't support the use of the terms "master" and "slave" that are usually used with Redis Sentinel. I don't think those are good terms to use, period. Instead, Redix uses the terms "primary" and "replica". If you're interested in the discussions around this, this issue in the Redis repository might be interesting to you.

Pub/Sub

A Redix.PubSub process can be started via Redix.PubSub.start_link/2:

{:ok, pubsub} = Redix.PubSub.start_link()

Most communication with the Redix.PubSub process happens via Elixir messages (that simulate a Pub/Sub interaction with the pub/sub server).

{:ok, pubsub} = Redix.PubSub.start_link()

Redix.PubSub.subscribe(pubsub, "my_channel", self())
#=> {:ok, ref}

Confirmation of subscriptions is delivered as an Elixir message:

receive do
  {:redix_pubsub, ^pubsub, ^ref, :subscribed, %{channel: "my_channel"}} -> :ok
end

If someone publishes a message on a channel we're subscribed to:

receive do
  {:redix_pubsub, ^pubsub, ^ref, :message, %{channel: "my_channel", payload: "hello"}} ->
    IO.puts("Received a message!")
end

Using Redix in the Real Worldβ„’

Redix is low-level, but it's still built to handle most things thrown at it. For many applications, you can avoid pooling with little to no impact on performance. Read the "Real world usage" page in the documentation for more information on this and pooling strategies that work better with Redix.

Contributing

To run the Redix test suite you will have to have Redis running locally. Redix requires a somewhat complex setup for running tests (because it needs a few instances running, for pub/sub and sentinel). For this reason, in this repository you'll find a docker-compose.yml file so that you can use Docker and docker-compose to spin up all the necessary Redis instances with just one command. Make sure you have Docker installed and then just run:

docker-compose up

Now, you're ready to run tests with the $ mix test command.

License

Redix is released under the MIT license. See the license file.

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].