Skip to content

Commit dbe9e1a

Browse files
committed
[#65] Migrate adapter to Nebulex V3
1 parent 9106372 commit dbe9e1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2741
-2413
lines changed

.formatter.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ locals_without_parens = [
55
]
66

77
[
8+
import_deps: [:nebulex],
89
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"],
910
line_length: 100,
1011
locals_without_parens: locals_without_parens,

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
jobs:
1212
nebulex_test:
1313
name: >-
14-
NebulexRedisAdapter Test (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }} /
14+
Nebulex.Adapters.Redis Test (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }} /
1515
OS ${{ matrix.os }})
1616
runs-on: ${{ matrix.os }}
1717

CHANGELOG.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ All notable changes to this project will be documented in this file.
44

55
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [v2.4.2](https://github.com/cabol/nebulex_redis_adapter/tree/v2.4.2) (2024-11-01)
8-
9-
[Full Changelog](https://github.com/cabol/nebulex_redis_adapter/compare/v2.4.1...v2.4.2)
10-
11-
**Closed issues:**
12-
13-
- `NebulexRedisAdapter.RedisCluster.Keyslot` incorrectly computes slot for
14-
hash tags.
15-
[#64](https://github.com/cabol/nebulex_redis_adapter/issues/64)
16-
177
## [v2.4.1](https://github.com/cabol/nebulex_redis_adapter/tree/v2.4.1) (2024-09-01)
188

199
[Full Changelog](https://github.com/cabol/nebulex_redis_adapter/compare/v2.4.0...v2.4.1)

README.md

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# NebulexRedisAdapter
1+
# Nebulex.Adapters.Redis
22
> Nebulex adapter for Redis (including [Redis Cluster][redis_cluster] support).
33
44
![CI](https://github.com/cabol/nebulex_redis_adapter/workflows/CI/badge.svg)
@@ -15,7 +15,7 @@ next sections.
1515
See also [online documentation][nbx_redis_adapter]
1616
and [Redis cache example][nbx_redis_example].
1717

18-
[nbx_redis_adapter]: http://hexdocs.pm/nebulex_redis_adapter/NebulexRedisAdapter.html
18+
[nbx_redis_adapter]: http://hexdocs.pm/nebulex_redis_adapter/Nebulex.Adapters.Redis.html
1919
[nbx_redis_example]: https://github.com/cabol/nebulex_examples/tree/master/redis_cache
2020
[redis_cluster]: https://redis.io/topics/cluster-tutorial
2121

@@ -51,7 +51,7 @@ After installing, we can define our cache to use Redis adapter as follows:
5151
defmodule MyApp.RedisCache do
5252
use Nebulex.Cache,
5353
otp_app: :my_app,
54-
adapter: NebulexRedisAdapter
54+
adapter: Nebulex.Adapters.Redis
5555
end
5656
```
5757

@@ -69,15 +69,15 @@ config :my_app, MyApp.RedisCache,
6969

7070
Since this adapter is implemented by means of `Redix`, it inherits the same
7171
options, including regular Redis options and connection options as well. For
72-
more information about the options, please check out `NebulexRedisAdapter`
72+
more information about the options, please check out `Nebulex.Adapters.Redis`
7373
module and also [Redix](https://github.com/whatyouhide/redix).
7474

7575
See also [Redis cache example][nbx_redis_example].
7676

7777
## Distributed Caching
7878

7979
There are different ways to support distributed caching when using
80-
**NebulexRedisAdapter**.
80+
**Nebulex.Adapters.Redis**.
8181

8282
### Redis Cluster
8383

@@ -95,7 +95,7 @@ Then we can define our cache which will use **Redis Cluster**:
9595
defmodule MyApp.RedisClusterCache do
9696
use Nebulex.Cache,
9797
otp_app: :my_app,
98-
adapter: NebulexRedisAdapter
98+
adapter: Nebulex.Adapters.Redis
9999
end
100100
```
101101

@@ -127,11 +127,11 @@ The pool of connections to the different master nodes is automatically
127127
configured by the adapter once it gets the cluster slots info.
128128

129129
> This one could be the easiest and recommended way for distributed caching
130-
using Redis and **NebulexRedisAdapter**.
130+
using Redis and **Nebulex.Adapters.Redis**.
131131

132132
### Client-side Cluster based on Sharding
133133

134-
**NebulexRedisAdapter** also brings with a simple client-side cluster
134+
**Nebulex.Adapters.Redis** also brings with a simple client-side cluster
135135
implementation based on Sharding distribution model.
136136

137137
We define our cache normally:
@@ -140,7 +140,7 @@ We define our cache normally:
140140
defmodule MyApp.ClusteredCache do
141141
use Nebulex.Cache,
142142
otp_app: :my_app,
143-
adapter: NebulexRedisAdapter
143+
adapter: Nebulex.Adapters.Redis
144144
end
145145
```
146146

@@ -182,9 +182,9 @@ config :my_app, MyApp.ClusteredCache,
182182
]
183183
```
184184

185-
By default, the adapter uses `NebulexRedisAdapter.ClientCluster.Keyslot` for the
186-
keyslot. Besides, if `:jchash` is defined as dependency, the adapter will use
187-
consistent-hashing automatically.
185+
By default, the adapter uses `Nebulex.Adapters.Redis.ClientSideCluster.Keyslot`
186+
for the keyslot. Besides, if `:jchash` is defined as dependency, the adapter
187+
will use consistent-hashing automatically.
188188

189189
> **NOTE:** It is highly recommended to define the `:jchash` dependency
190190
when using the adapter in `:client_side_cluster` mode.
@@ -224,28 +224,28 @@ config :my_app, MyApp.ClusteredCache,
224224
### Using `Nebulex.Adapters.Partitioned`
225225

226226
Another simple option is to use the `Nebulex.Adapters.Partitioned` and set as
227-
local cache the `NebulexRedisAdapter`. The idea here is each Elixir node running
228-
the distributed cache (`Nebulex.Adapters.Partitioned`) will have as local
229-
backend or cache a Redis instance (handled by `NebulexRedisAdapter`).
227+
local cache the `Nebulex.Adapters.Redis`. The idea here is each Elixir node
228+
running the distributed cache (`Nebulex.Adapters.Partitioned`) will have as
229+
local backend or cache a Redis instance (handled by `Nebulex.Adapters.Redis`).
230230

231231

232232
This example shows how the setup a distributed cache using
233-
`Nebulex.Adapters.Partitioned` and `NebulexRedisAdapter`:
233+
`Nebulex.Adapters.Partitioned` and `Nebulex.Adapters.Redis`:
234234

235235
```elixir
236236
defmodule MyApp.DistributedCache do
237237
use Nebulex.Cache,
238238
otp_app: :my_app,
239239
adapter: Nebulex.Adapters.Partitioned,
240-
primary_storage_adapter: NebulexRedisAdapter
240+
primary_storage_adapter: Nebulex.Adapters.Redis
241241
end
242242
```
243243

244244
### Using a Redis Proxy
245245

246246
The other option is to use a proxy, like [Envoy proxy][envoy] or
247247
[Twemproxy][twemproxy] on top of Redis. In this case, the proxy does the
248-
distribution work, and from the adparter's side (**NebulexRedisAdapter**),
248+
distribution work, and from the adparter's side (**Nebulex.Adapters.Redis**),
249249
it would be only configuration. Instead of connect the adapter against the
250250
Redis nodes, we connect it against the proxy nodes, this means, in the config,
251251
we setup the pool with the host and port pointing to the proxy.
@@ -255,13 +255,13 @@ we setup the pool with the host and port pointing to the proxy.
255255

256256
## Running Redis commands and/or pipelines
257257

258-
Since `NebulexRedisAdapter` works on top of `Redix` and provides features like
259-
connection pools and "Redis Cluster" support, it may be seen also as a sort of
260-
Redis client, but it is meant to be used mainly with the Nebulex cache API.
261-
However, Redis API is quite extensive and there are a lot of useful commands
262-
we may want to run taking advantage of the `NebulexRedisAdapter` features.
263-
Therefore, the adapter injects two additional/extended functions to the
264-
defined cache: `command!/2` and `pipeline!/2`.
258+
Since `Nebulex.Adapters.Redis` works on top of `Redix` and provides features
259+
like connection pools and "Redis Cluster" support, it may be seen also as a
260+
sort of Redis client, but it is meant to be used mainly with the Nebulex cache
261+
API. However, Redis API is quite extensive and there are a lot of useful
262+
commands we may want to run taking advantage of the `Nebulex.Adapters.Redis`
263+
features. Therefore, the adapter injects two additional/extended functions
264+
to the defined cache: `command!/2` and `pipeline!/2`.
265265

266266
```elixir
267267
iex> MyCache.command!(["LPUSH", "mylist", "world"], key: "mylist")
@@ -287,8 +287,8 @@ you have to pass the cache name explicitly.
287287

288288
## Testing
289289

290-
To run the **NebulexRedisAdapter** tests you will have to have Redis running
291-
locally. **NebulexRedisAdapter** requires a complex setup for running tests
290+
To run the **Nebulex.Adapters.Redis** tests you will have to have Redis running
291+
locally. **Nebulex.Adapters.Redis** requires a complex setup for running tests
292292
(since it needs a few instances running, for standalone, cluster and Redis
293293
Cluster). For this reason, there is a [docker-compose.yml](docker-compose.yml)
294294
file in the repo so that you can use [Docker][docker] and
@@ -302,7 +302,7 @@ $ docker-compose up
302302
[docker]: https://www.docker.com/
303303
[docker_compose]: https://docs.docker.com/compose/
304304

305-
Since `NebulexRedisAdapter` uses the support modules and shared tests
305+
Since `Nebulex.Adapters.Redis` uses the support modules and shared tests
306306
from `Nebulex` and by default its test folder is not included in the Hex
307307
dependency, the following steps are required for running the tests.
308308

@@ -373,4 +373,4 @@ all checks run successfully.
373373

374374
Copyright (c) 2018, Carlos Bolaños.
375375

376-
NebulexRedisAdapter source code is licensed under the [MIT License](LICENSE).
376+
Nebulex.Adapters.Redis source code is licensed under the [MIT License](LICENSE).

config/test.exs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import Config
22

33
# Standalone mode
4-
config :nebulex_redis_adapter, NebulexRedisAdapter.TestCache.Standalone,
4+
config :nebulex_redis_adapter, Nebulex.Adapters.Redis.TestCache.Standalone,
55
conn_opts: [
66
host: "127.0.0.1",
77
port: 6379
88
]
99

10-
# Cluster mode
11-
config :nebulex_redis_adapter, NebulexRedisAdapter.TestCache.ClientCluster,
10+
# Client-side cluster mode
11+
config :nebulex_redis_adapter, Nebulex.Adapters.Redis.TestCache.ClientSideCluster,
1212
mode: :client_side_cluster,
1313
client_side_cluster: [
1414
nodes: [
@@ -34,7 +34,7 @@ config :nebulex_redis_adapter, NebulexRedisAdapter.TestCache.ClientCluster,
3434
]
3535

3636
# Redis Cluster mode (with Redis >= 7)
37-
config :nebulex_redis_adapter, NebulexRedisAdapter.TestCache.RedisCluster,
37+
config :nebulex_redis_adapter, Nebulex.Adapters.Redis.TestCache.RedisCluster,
3838
mode: :redis_cluster,
3939
redis_cluster: [
4040
# Configuration endpoints
@@ -51,7 +51,7 @@ config :nebulex_redis_adapter, NebulexRedisAdapter.TestCache.RedisCluster,
5151
]
5252

5353
# Redis Cluster mode with errors
54-
config :nebulex_redis_adapter, NebulexRedisAdapter.TestCache.RedisClusterConnError,
54+
config :nebulex_redis_adapter, Nebulex.Adapters.Redis.TestCache.RedisClusterConnError,
5555
mode: :redis_cluster,
5656
pool_size: 2,
5757
redis_cluster: [

coveralls.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"skip_files": [
3-
"lib/nebulex_redis_adapter/exceptions.ex",
4-
"lib/nebulex_redis_adapter/helpers.ex",
5-
"lib/nebulex_redis_adapter/serializer.ex",
3+
"lib/nebulex/adapters/redis/helpers.ex",
4+
"lib/nebulex/adapters/redis/serializer.ex",
5+
"lib/nebulex/adapters/redis/serializer/serializable.ex",
6+
"lib/nebulex/adapters/redis/options.ex",
7+
"lib/nebulex/adapters/redis/error_formatter.ex",
68
"test/*"
79
],
810
"coverage_options": {

0 commit comments

Comments
 (0)