Skip to content

Commit 58e0b26

Browse files
committed
Update nebulex
1 parent 2c2ea47 commit 58e0b26

File tree

7 files changed

+178
-86
lines changed

7 files changed

+178
-86
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ jobs:
1919
matrix:
2020
include:
2121
- elixir: 1.18.x
22-
otp: 27.x
22+
otp: 28.x
2323
os: 'ubuntu-latest'
2424
lint: true
2525
coverage: true
2626
dialyzer: true
27+
- elixir: 1.17.x
28+
otp: 27.x
29+
os: 'ubuntu-latest'
2730
- elixir: 1.15.x
2831
otp: 25.x
2932
os: 'ubuntu-latest'
@@ -94,13 +97,13 @@ jobs:
9497
- name: Run tests
9598
run: |
9699
epmd -daemon
97-
mix test --exclude nebulex_test
100+
mix test --exclude cluster_queryable_test --exclude redis_cluster
98101
if: ${{ !matrix.coverage }}
99102

100103
- name: Run tests with coverage
101104
run: |
102105
epmd -daemon
103-
mix coveralls.json --exclude nebulex_test
106+
mix coveralls.json --exclude cluster_queryable_test
104107
if: ${{ matrix.coverage }}
105108

106109
- name: Upload coverage reports to Codecov

README.md

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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)
@@ -9,12 +9,12 @@
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

3333
Add `:nebulex_redis_adapter` to your list of dependencies in `mix.exs`:
3434

@@ -42,19 +42,19 @@ defp deps do
4242
end
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

5353
Then 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
6060
defmodule MyApp.RedisCache do
@@ -64,7 +64,7 @@ defmodule MyApp.RedisCache do
6464
end
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
6868
defined 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]
8585
for 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

9292
There 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
100100
the `: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
108108
defmodule MyApp.RedisClusterCache do
@@ -112,7 +112,7 @@ defmodule MyApp.RedisClusterCache do
112112
end
113113
```
114114

115-
The config:
115+
The configuration:
116116

117117
```elixir
118118
config :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

139139
The 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
153153
defmodule MyApp.ClusteredCache do
@@ -157,7 +157,7 @@ defmodule MyApp.ClusteredCache do
157157
end
158158
```
159159

160-
The config:
160+
The configuration:
161161

162162
```elixir
163163
config :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

212212
Since 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
215215
want to run, leveraging the Redis adapter features. Therefore, the adapter
216216
provides 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
244244
locally. **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
259259
from `Nebulex` and by default its test folder is not included in the Hex
260260
dependency, 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`
263263
to `nebulex`:
264264

265-
```
265+
```bash
266266
export 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
270270
by running:
271271

272-
```
272+
```bash
273273
mix nbx.setup
274274
```
275275

276-
Third, fetch deps:
276+
Third, fetch the dependencies:
277277

278-
```
278+
```bash
279279
mix deps.get
280280
```
281281

282282
Finally, you can run the tests:
283283

284-
```
284+
```bash
285285
mix test
286286
```
287287

288288
Running tests with coverage:
289289

290-
```
290+
```bash
291291
mix coveralls.html
292292
```
293293

294294
You will find the coverage report within `cover/excoveralls.html`.
295295

296-
## Benchmarks
296+
## 📊 Benchmarks
297297

298298
Benchmarks were added using [benchee](http://github.com/PragTob/benchee);
299299
to learn more, see the [benchmarks](./benchmarks) directory.
300300

301301
To run the benchmarks:
302302

303-
```
303+
```bash
304304
mix 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

311311
Contributions 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)
316316
when 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
320320
alongside 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
323323
all checks run successfully.
324324

325-
## Copyright and License
325+
## 📄 Copyright and License
326326

327327
Copyright (c) 2018, Carlos Bolaños.
328328

mix.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ defmodule Nebulex.Adapters.Redis.MixProject do
33

44
@source_url "http://github.com/elixir-nebulex/nebulex_redis_adapter"
55
@version "3.0.0-rc.1"
6-
@nbx_tag "3.0.0-rc.1"
7-
@nbx_vsn "3.0.0-rc.1"
6+
# @nbx_tag "3.0.0-rc.1"
7+
# @nbx_vsn "3.0.0-rc.1"
88

99
def project do
1010
[
@@ -76,15 +76,15 @@ defmodule Nebulex.Adapters.Redis.MixProject do
7676
if path = System.get_env("NEBULEX_PATH") do
7777
{:nebulex, path: path}
7878
else
79-
{:nebulex, "~> #{@nbx_vsn}"}
79+
{:nebulex, github: "elixir-nebulex/nebulex"}
8080
end
8181
end
8282

8383
defp aliases do
8484
[
8585
"nbx.setup": [
8686
"cmd rm -rf nebulex",
87-
"cmd git clone --depth 1 --branch v#{@nbx_tag} http://github.com/elixir-nebulex/nebulex"
87+
"cmd git clone --depth 1 --branch main http://github.com/elixir-nebulex/nebulex"
8888
],
8989
"test.ci": [
9090
"deps.unlock --check-unused",

0 commit comments

Comments
 (0)