1- # Nebulex.Adapters.Redis
1+ # Nebulex.Adapters.Redis 🧱⚡
22> Nebulex adapter for Redis (including [ Redis Cluster] [ redis_cluster ] support).
33
44![ CI] ( http://github.com/elixir-nebulex/nebulex_redis_adapter/workflows/CI/badge.svg )
99[ redis_cluster ] : http://redis.io/topics/cluster-tutorial
1010[ redix ] : http://github.com/whatyouhide/redix
1111
12- ## About
12+ ## 📖 About
1313
14- This adapter uses [ Redix] [ redix ] ; a Redis driver for Elixir.
14+ This adapter uses [ Redix] [ redix ] - a Redis driver for Elixir.
1515
16- The adapter supports different configurations modes which are explained in the
17- next sections.
16+ The adapter supports different configuration modes, which are explained in the
17+ following sections.
1818
1919---
2020
@@ -28,7 +28,7 @@ next sections.
2828
2929---
3030
31- ## Installation
31+ ## 🚀 Installation
3232
3333Add ` :nebulex_redis_adapter ` to your list of dependencies in ` mix.exs ` :
3434
@@ -42,19 +42,19 @@ defp deps do
4242end
4343```
4444
45- The adapter dependencies are optional to give more flexibility and loading only
46- needed ones. For example:
45+ The adapter dependencies are optional to provide more flexibility and load only
46+ the needed ones. For example:
4747
48- * ` :crc ` - Required when using the adapter in mode ` :redis_cluster ` .
49- See [ Redis Cluster] [ redis_cluster ] .
50- * ` :ex_hash_ring ` - Required when using the adapter in mode
51- ` :client_side_cluster ` .
48+ * ` :crc ` - Required when using the adapter in ` :redis_cluster ` mode .
49+ See [ Redis Cluster] [ redis_cluster ] .
50+ * ` :ex_hash_ring ` - Required when using the adapter in
51+ ` :client_side_cluster ` mode .
5252
5353Then run ` mix deps.get ` to fetch the dependencies.
5454
55- ## Usage
55+ ## 💻 Usage
5656
57- After installing, we can define our cache to use Redis adapter as follows:
57+ After installing, you can define your cache to use the Redis adapter as follows:
5858
5959``` elixir
6060defmodule MyApp .RedisCache do
@@ -64,7 +64,7 @@ defmodule MyApp.RedisCache do
6464end
6565```
6666
67- The rest of Redis configuration is set in our application environment, usually
67+ The Redis configuration is set in your application environment, usually
6868defined in your ` config/config.exs ` :
6969
7070``` elixir
@@ -76,33 +76,33 @@ config :my_app, MyApp.RedisCache,
7676 ]
7777```
7878
79- Since this adapter is implemented by means of ` Redix ` , it inherits the same
80- options, including regular Redis options and connection options as well . For
81- more information about the options, please check out ` Nebulex.Adapters.Redis `
82- module and also [ Redix] [ redix ] .
79+ Since this adapter is implemented using ` Redix ` , it inherits the same
80+ options, including regular Redis options and connection options. For
81+ more information about the options, please check out the
82+ ` Nebulex.Adapters.Redis ` module and also [ Redix] [ redix ] .
8383
84- See [ online documentation] [ docs ] and [ Redis cache example] [ redis_example ]
84+ See the [ online documentation] [ docs ] and [ Redis cache example] [ redis_example ]
8585for more information.
8686
8787[ docs ] : http://hexdocs.pm/nebulex_redis_adapter/3.0.0-rc.1/Nebulex.Adapters.Redis.html
8888[ redis_example ] : http://github.com/elixir-nebulex/nebulex_examples/tree/master/redis_cache
8989
90- ## Distributed Caching
90+ ## 🌐 Distributed Caching
9191
9292There are different ways to support distributed caching when using
9393** Nebulex.Adapters.Redis** .
9494
95- ### Redis Cluster
95+ ### 🏗️ Redis Cluster
9696
9797[ Redis Cluster] [ redis_cluster ] is a built-in feature in Redis since version 3,
98- and it may be the most convenient and recommendable way to set up Redis in a
99- cluster and have a distributed cache storage out-of-box. This adapter provides
98+ and it may be the most convenient and recommended way to set up Redis in a
99+ cluster and have distributed cache storage out-of-the -box. This adapter provides
100100the ` :redis_cluster ` mode to set up ** Redis Cluster** from the client-side
101- automatically and be able to use it transparently.
101+ automatically and use it transparently.
102102
103- First of all , ensure you have ** Redis Cluster** configured and running.
103+ First, ensure you have ** Redis Cluster** configured and running.
104104
105- Then we can define our cache which will use ** Redis Cluster** :
105+ Then you can define your cache which will use ** Redis Cluster** :
106106
107107``` elixir
108108defmodule MyApp .RedisClusterCache do
@@ -112,7 +112,7 @@ defmodule MyApp.RedisClusterCache do
112112end
113113```
114114
115- The config :
115+ The configuration :
116116
117117``` elixir
118118config :my_app , MyApp .RedisClusterCache ,
@@ -129,25 +129,25 @@ config :my_app, MyApp.RedisClusterCache,
129129 endpoint1_conn_opts: [
130130 host: " 127.0.0.1" ,
131131 port: 6379 ,
132- # Add the password if 'requirepass' is on
132+ # Add the password if 'requirepass' is enabled
133133 password: " password"
134134 ]
135135 ]
136136 ]
137137```
138138
139139The pool of connections to the different master nodes is automatically
140- configured by the adapter once it gets the cluster slots info .
140+ configured by the adapter once it gets the cluster slots information .
141141
142- > This one could be the easiest and recommended way for distributed caching
142+ > This could be the easiest and recommended way for distributed caching
143143 using Redis and ** Nebulex.Adapters.Redis** .
144144
145- ### Client-side Cluster
145+ ### 🔗 Client-side Cluster
146146
147- ** Nebulex.Adapters.Redis** also brings with a simple client-side cluster
148- implementation based on sharding distribution model.
147+ ** Nebulex.Adapters.Redis** also provides a simple client-side cluster
148+ implementation based on a sharding distribution model.
149149
150- We define our cache normally:
150+ Define your cache normally:
151151
152152``` elixir
153153defmodule MyApp .ClusteredCache do
@@ -157,7 +157,7 @@ defmodule MyApp.ClusteredCache do
157157end
158158```
159159
160- The config :
160+ The configuration :
161161
162162``` elixir
163163config :my_app , MyApp .ClusteredCache ,
@@ -190,28 +190,28 @@ config :my_app, MyApp.ClusteredCache,
190190 port: 9003
191191 ]
192192 ]
193- # Maybe more ...
193+ # Maybe more nodes ...
194194 ]
195195 ]
196196```
197197
198- ### Using a Redis Proxy
198+ ### 🌉 Using a Redis Proxy
199199
200- The other option is to use a proxy, like [ Envoy proxy] [ envoy ] or
201- [ Twemproxy] [ twemproxy ] on top of Redis. In this case, the proxy does the
202- distribution work, and from the adparter 's side (** Nebulex.Adapters.Redis** ),
203- it would be only configuration. Instead of connect the adapter against the
204- Redis nodes, we connect it against the proxy nodes, this means, in the config,
205- we setup the pool with the host and port pointing to the proxy.
200+ Another option is to use a proxy, such as [ Envoy proxy] [ envoy ] or
201+ [ Twemproxy] [ twemproxy ] , on top of Redis. In this case, the proxy handles the
202+ distribution work, and from the adapter 's side (** Nebulex.Adapters.Redis** ),
203+ it would only require configuration. Instead of connecting the adapter to the
204+ Redis nodes, you connect it to the proxy nodes. This means in the config,
205+ you set up the pool with the host and port pointing to the proxy.
206206
207207[ envoy ] : http://www.envoyproxy.io/
208208[ twemproxy ] : http://github.com/twitter/twemproxy
209209
210- ## Using the adapter as a Redis client
210+ ## 🔧 Using the Adapter as a Redis Client
211211
212212Since the Redis adapter works on top of ` Redix ` and provides features like
213- connection pools, "Redis Cluster", etc., it may also work as a Redis client.
214- The Redis API is quite extensive, and there are many useful commands we may
213+ connection pools, "Redis Cluster", etc., it can also work as a Redis client.
214+ The Redis API is quite extensive, and there are many useful commands you may
215215want to run, leveraging the Redis adapter features. Therefore, the adapter
216216provides additional functions to do so.
217217
@@ -238,17 +238,17 @@ iex> Redix.pipeline!(conn, [
238238> The ` :name ` may be needed when using dynamic caches, and the ` :key ` is
239239> required when using the ` :redis_cluster ` or ` :client_side_cluster ` mode.
240240
241- ## Testing
241+ ## 🧪 Testing
242242
243- To run the ** Nebulex.Adapters.Redis** tests you will have to have Redis running
243+ To run the ** Nebulex.Adapters.Redis** tests, you will need to have Redis running
244244locally. ** Nebulex.Adapters.Redis** requires a complex setup for running tests
245- (since it needs a few instances running, for standalone, cluster and Redis
246- Cluster). For this reason, there is a [ docker-compose.yml] ( docker-compose.yml )
247- file in the repo so that you can use [ Docker] [ docker ] and
248- [ docker-compose ] [ docker_compose ] to spin up all the necessary Redis instances
249- with just one command. Make sure you have Docker installed and then just run:
245+ (since it needs several instances running for standalone, cluster, and Redis
246+ Cluster modes ). For this reason, there is a [ docker-compose.yml] ( docker-compose.yml )
247+ file in the repo so you can use [ Docker] [ docker ] and [ docker-compose ] [ docker_compose ]
248+ to spin up all the necessary Redis instances with just one command. Make sure
249+ you have Docker installed and then just run:
250250
251- ```
251+ ``` bash
252252$ docker-compose up
253253```
254254
@@ -259,54 +259,54 @@ Since `Nebulex.Adapters.Redis` uses the support modules and shared tests
259259from ` Nebulex ` and by default its test folder is not included in the Hex
260260dependency, the following steps are required for running the tests.
261261
262- First of all , make sure you set the environment variable ` NEBULEX_PATH `
262+ First, make sure you set the environment variable ` NEBULEX_PATH `
263263to ` nebulex ` :
264264
265- ```
265+ ``` bash
266266export NEBULEX_PATH=nebulex
267267```
268268
269- Second, make sure you fetch ` :nebulex ` dependency directly from GtiHub
269+ Second, make sure you fetch the ` :nebulex ` dependency directly from GitHub
270270by running:
271271
272- ```
272+ ``` bash
273273mix nbx.setup
274274```
275275
276- Third, fetch deps :
276+ Third, fetch the dependencies :
277277
278- ```
278+ ``` bash
279279mix deps.get
280280```
281281
282282Finally, you can run the tests:
283283
284- ```
284+ ``` bash
285285mix test
286286```
287287
288288Running tests with coverage:
289289
290- ```
290+ ``` bash
291291mix coveralls.html
292292```
293293
294294You will find the coverage report within ` cover/excoveralls.html ` .
295295
296- ## Benchmarks
296+ ## 📊 Benchmarks
297297
298298Benchmarks were added using [ benchee] ( http://github.com/PragTob/benchee ) ;
299299to learn more, see the [ benchmarks] ( ./benchmarks ) directory.
300300
301301To run the benchmarks:
302302
303- ```
303+ ``` bash
304304mix run benchmarks/benchmark.exs
305305```
306306
307307> Benchmarks use default Redis options (` host: "127.0.0.1", port: 6379 ` ).
308308
309- ## Contributing
309+ ## 🤝 Contributing
310310
311311Contributions to Nebulex are very welcome and appreciated!
312312
@@ -315,14 +315,14 @@ for bug reports or feature requests. Open a
315315[ pull request] ( http://github.com/elixir-nebulex/nebulex_redis_adapter/pulls )
316316when you are ready to contribute.
317317
318- When submitting a pull request you should not update the [ CHANGELOG.md] ( CHANGELOG.md ) ,
319- and also make sure you test your changes thoroughly, include unit tests
318+ When submitting a pull request, you should not update the [ CHANGELOG.md] ( CHANGELOG.md ) ,
319+ and also make sure you test your changes thoroughly, including unit tests
320320alongside new or changed code.
321321
322- Before to submit a PR it is highly recommended to run ` mix test.ci ` and ensure
322+ Before submitting a PR, it is highly recommended to run ` mix test.ci ` and ensure
323323all checks run successfully.
324324
325- ## Copyright and License
325+ ## 📄 Copyright and License
326326
327327Copyright (c) 2018, Carlos Bolaños.
328328
0 commit comments