Skip to content

Commit 0060c63

Browse files
committed
Update nebulex and add Redis example
1 parent 3866095 commit 0060c63

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

+535
-123
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
erl_crash.dump
55
*.ez
66
*.beam
7+
.elixir*
8+
.DS_Store

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# Nebulex Examples
22

3-
* [Partitioned Cache](./partitioned_cache) - Partitioned cache topology example.
3+
- [Partitioned Cache](./partitioned_cache) - Partitioned cache topology example.
44

5-
* [Near Cache](./near_cache) - Near cache topology example. This example uses
5+
- [Near Cache](./near_cache) - Near cache topology example. This example uses
66
all built-in adapters (Multilevel, Distributed and Local).
77

8-
* [Nebulex-Ecto Integration](./nebulex_ecto_example) - Integrate Nebulex and
8+
- [Redis Cache](./redis_cache) - Redis cache example. This example shows how to
9+
use the `NebulexRedisAdapter` in different modes and also in a multilevel
10+
topology.
11+
12+
- [Nebulex-Ecto Integration](./nebulex_ecto_example) - Integrate Nebulex and
913
Ecto extremely easy using [declarative annotation-based caching via decorators](http://hexdocs.pm/nebulex/Nebulex.Caching.html).
1014

11-
* [Instrumenting Caches with Telemetry](./nebulex_telemetry_example) - An example
15+
- [Instrumenting Caches with Telemetry](./nebulex_telemetry_example) - An example
1216
that illustrates how to instrument our Nebulex caches using Telemetry.
1317

14-
* [Erlang Example](./erlang_cache) - An example that illustrates how to use
15-
Nebulex from an Erlang app.
16-
17-
* [Nebulex Bench](./nebulex_bench) - This example shows how to run bench or load
18+
- [Nebulex Bench](./nebulex_bench) - This example shows how to run bench or load
1819
tests for `Nebulex` using [basho_bench](https://github.com/mrallen1/basho_bench).
20+
21+
- [Erlang Example](./erlang_cache) - An example that illustrates how to use
22+
Nebulex from an Erlang app.

erlang_cache/elixir_libs/nbx_cache/config/config.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Mix.Config
1+
import Config
22

33
config :erlang_cache, NbxCache,
44
gc_interval: :timer.seconds(86_400),

erlang_cache/elixir_libs/nbx_cache/mix.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ defmodule NbxCache.MixProject do
1818

1919
defp deps do
2020
[
21-
{:nebulex, "~> 2.0-pre"},
22-
{:shards, "~> 0.6"}
21+
{:nebulex, "~> 2.0.0-rc.1"},
22+
{:shards, "~> 1.0"}
2323
]
2424
end
2525
end
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
%{
2-
"decorator": {:hex, :decorator, "1.3.2", "63b8ac9e23b28053390abdda33bb9e1f3dd9e8f9a981f47a06fc2f2fe2e2f772", [:mix], [], "hexpm", "b80bd089e3c8579e6d9ea84eed307b1597a0d94af25331e424a209477ad1a7fc"},
3-
"nebulex": {:hex, :nebulex, "2.0.0-rc.0", "fd7c3c98373bcb64392bbbc6eb7af97effc34ae8ae9597becc7cd849836895bf", [:mix], [{:decorator, "~> 1.3", [hex: :decorator, repo: "hexpm", optional: true]}, {:shards, "~> 0.6", [hex: :shards, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.2", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "3ffbe0c4cddd15fa9ab201cc1aa69ad21db862313097025dee5c77b73ad91003"},
4-
"shards": {:hex, :shards, "0.6.2", "e05d05537883220c3b8a8f9d40d5c8ba7ff6064c63ebb6b23046972f6863b2d1", [:make, :rebar3], [], "hexpm", "58afa3712f1f1256a2a15e39fa95b7cd758087aaa7a25beaf786daabd87890f0"},
2+
"nebulex": {:hex, :nebulex, "2.0.0-rc.1", "ad9fdc3b2b91b7de9d55dabfaac2994b91be29602b2715daf530bdd54509b4db", [:mix], [{:decorator, "~> 1.3", [hex: :decorator, repo: "hexpm", optional: true]}, {:shards, "~> 1.0", [hex: :shards, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: true]}], "hexpm", "1d78bd1f9e648e5600cb2a349114957296f824641b57e72545ace6cb6cc22110"},
3+
"shards": {:hex, :shards, "1.0.1", "1bdbbf047db27f3c3eb800a829d4a47062c84d5543cbfebcfc4c14d038bf9220", [:make, :rebar3], [], "hexpm", "2c57788afbf053c4024366772892beee89b8b72e884e764fb0a075dfa7442041"},
54
}

erlang_cache/rebar.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
]}.
66

77
{deps, [
8-
{nebulex, {elixir, "nebulex" ,"2.0.0-rc.0"}},
9-
{shards, "0.6.2"}
8+
{nebulex, {elixir, "nebulex" ,"2.0.0-rc.1"}},
9+
{shards, "1.0.1"}
1010
]}.
1111

1212
{provider_hooks, [

near_cache/config/config.exs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
use Mix.Config
1+
import Config
22

33
# L1 Cache
44
config :near_cache, NearCache,
55
model: :inclusive,
66
levels: [
7-
l1: [
8-
adapter: Nebulex.Adapters.Local,
7+
{
8+
NearCache.L1,
99
gc_interval: :timer.seconds(86_400),
1010
backend: :shards
11-
],
12-
l2: [
13-
adapter: Nebulex.Adapters.Partitioned,
11+
},
12+
{
13+
NearCache.L2,
1414
primary: [
1515
adapter: Nebulex.Adapters.Local,
1616
gc_interval: :timer.seconds(86_400),
1717
backend: :shards
1818
]
19-
]
19+
}
2020
]
2121

2222
# NearCache config

near_cache/lib/near_cache.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,16 @@ defmodule NearCache do
22
use Nebulex.Cache,
33
otp_app: :near_cache,
44
adapter: Nebulex.Adapters.Multilevel
5+
6+
defmodule L1 do
7+
use Nebulex.Cache,
8+
otp_app: :near_cache,
9+
adapter: Nebulex.Adapters.Local
10+
end
11+
12+
defmodule L2 do
13+
use Nebulex.Cache,
14+
otp_app: :near_cache,
15+
adapter: Nebulex.Adapters.Partitioned
16+
end
517
end

near_cache/lib/near_cache/hooks.ex

Lines changed: 0 additions & 25 deletions
This file was deleted.

near_cache/lib/near_cache/jumping_hash_slot.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
defmodule NearCache.JumpingHashSlot do
2-
@behaviour Nebulex.Adapter.HashSlot
2+
use Nebulex.Adapter.Keyslot
33

44
@doc """
55
This function uses [Jump Consistent Hash](https://github.com/cabol/jchash).
66
"""
77
@impl true
8-
def keyslot(key, range) do
8+
def hash_slot(key, range) do
99
key
1010
|> :erlang.phash2()
1111
|> :jchash.compute(range)

0 commit comments

Comments
 (0)