Skip to content

Commit

Permalink
Merge branch 'master' into gc-flush-delay
Browse files Browse the repository at this point in the history
  • Loading branch information
szajbus committed Jul 14, 2023
2 parents eb1e727 + 974f54e commit e80690c
Show file tree
Hide file tree
Showing 18 changed files with 242 additions and 130 deletions.
18 changes: 17 additions & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
locals_without_parens = [
# Nebulex.Caching
keyref: 1,
keyref: 2,

# Tests
deftests: 1,
deftests: 2,
setup_with_cache: 1,
setup_with_cache: 2,
setup_with_dynamic_cache: 2,
setup_with_dynamic_cache: 3
]

[
import_deps: [:stream_data],
inputs: ["{mix,.formatter}.exs", "{config,lib,test,benchmarks}/**/*.{ex,exs}"],
line_length: 100
line_length: 100,
locals_without_parens: locals_without_parens,
export: [locals_without_parens: locals_without_parens]
]
82 changes: 82 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,88 @@ All notable changes to this project will be documented in this file.

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

## [v2.5.1](https://github.com/cabol/nebulex/tree/v2.5.1) (2023-05-27)

[Full Changelog](https://github.com/cabol/nebulex/compare/v2.5.0...v2.5.1)

**Merged pull requests:**

- Fix `nil` check in `Nebulex.Adapters.Multilevel.get/3`
[#205](https://github.com/cabol/nebulex/pull/205)
([1100x1100](https://github.com/1100x1100))
- `mix nbx.gen.cache` example fixed
[#204](https://github.com/cabol/nebulex/pull/204)
([hissssst](https://github.com/hissssst))

## [v2.5.0](https://github.com/cabol/nebulex/tree/v2.5.0) (2023-05-13)

[Full Changelog](https://github.com/cabol/nebulex/compare/v2.4.2...v2.5.0)

**Implemented enhancements:**

- Support for functions that can set TTL in Decorator similar to Match
[#200](https://github.com/cabol/nebulex/issues/200)
- Improve default match function in decorators to cover more scenarios
[#177](https://github.com/cabol/nebulex/issues/177)
- Adapters implementation guide
[#96](https://github.com/cabol/nebulex/issues/96)

**Fixed bugs:**

- Issue with keys set to `false` when calling `get_all` in local adapter
[#187](https://github.com/cabol/nebulex/issues/187)

**Closed issues:**

- Is there any way to get the size of the cache?
[#203](https://github.com/cabol/nebulex/issues/203)
- Where to use load/2, dump/2
[#201](https://github.com/cabol/nebulex/issues/201)
- `Nebulex.Cache` callbacks mention "Shared Options" section that do not exist
[#199](https://github.com/cabol/nebulex/issues/199)
- Errors when storing nil values
[#195](https://github.com/cabol/nebulex/issues/195)
- Unregistering cache in registry happens after cache shuts down
[#194](https://github.com/cabol/nebulex/issues/194)
- Is there a good way to evict multiple caches at once by some conditions?
[#192](https://github.com/cabol/nebulex/issues/192)
- Unable to use module attributes when specifying a MFA cache within the decorator
[#191](https://github.com/cabol/nebulex/issues/191)
- Nebulex crash when `gc_interval` is not set
[#182](https://github.com/cabol/nebulex/issues/182)
- `ArgumentError` * 1st argument: the table identifier does not refer to an existing ETS table
[#181](https://github.com/cabol/nebulex/issues/181)
- Feedback for `NebulexLocalDistributedAdapter`
[#180](https://github.com/cabol/nebulex/issues/180)
- Multilevel invalidation
[#179](https://github.com/cabol/nebulex/issues/179)
- External cache-key references on `cacheable` decorator
[#178](https://github.com/cabol/nebulex/issues/178)
- [multiple clause functions] Cannot use ignored variables in decorator keys
[#173](https://github.com/cabol/nebulex/issues/173)
- Ability for referencing a key in the `cacheable` decorator via `:references` option
[#169](https://github.com/cabol/nebulex/issues/169)
- Multi level caching suggestion?
[#168](https://github.com/cabol/nebulex/issues/168)

**Merged pull requests:**

- Fix `Local.get_all` with false values
[#186](https://github.com/cabol/nebulex/pull/186)
([renatoaguiar](https://github.com/renatoaguiar))
- Add NebulexLocalMultilevelAdapter to the list
[#185](https://github.com/cabol/nebulex/pull/185)
([martosaur](https://github.com/martosaur))
- Fix the crash when `gc_interval` is not set
[#183](https://github.com/cabol/nebulex/pull/183)
([dongfuye](https://github.com/dongfuye))
- [#169] Reference a key in `cacheable` decorator via `:references` option
[#176](https://github.com/cabol/nebulex/pull/176)
([cabol](https://github.com/cabol))
- Creating New Adapter guide
[#175](https://github.com/cabol/nebulex/pull/175)
([martosaur](https://github.com/martosaur))

## [v2.4.2](https://github.com/cabol/nebulex/tree/v2.4.2) (2022-11-04)

[Full Changelog](https://github.com/cabol/nebulex/compare/v2.4.1...v2.4.2)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ For example, if you want to use a built-in cache, add to your `mix.exs` file:
```elixir
def deps do
[
{:nebulex, "~> 2.4"},
{:shards, "~> 1.0"}, #=> When using :shards as backend
{:nebulex, "~> 2.5"},
{:shards, "~> 1.1"}, #=> When using :shards as backend
{:decorator, "~> 1.4"}, #=> When using Caching Annotations
{:telemetry, "~> 1.0"} #=> When using the Telemetry events (Nebulex stats)
]
Expand Down
6 changes: 3 additions & 3 deletions guides/creating-new-adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Now let's modify `mix.exs` so that we could fetch Nebulex repository.
defmodule NebulexMemoryAdapter.MixProject do
use Mix.Project

@nbx_vsn "2.4.2"
@nbx_vsn "2.5.0"
@version "0.1.0"

def project do
Expand Down Expand Up @@ -231,10 +231,10 @@ mix test
54) test put_all/2 puts the given entries using different data types at once (NebulexMemoryAdapterTest)
test/nebulex_memory_adapter_test.exs:128
** (UndefinedFunctionError) function NebulexMemoryAdapter.TestCache.delete_all/0 is undefined or private. Did you mean:

* delete/1
* delete/2

stacktrace:
(nebulex_memory_adapter 0.1.0) NebulexMemoryAdapter.TestCache.delete_all()
test/nebulex_memory_adapter_test.exs:9: NebulexMemoryAdapterTest.__ex_unit_setup_0/1
Expand Down
2 changes: 1 addition & 1 deletion guides/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ changing the `deps` definition in that file to this:
```elixir
defp deps do
[
{:nebulex, "~> 2.4"},
{:nebulex, "~> 2.5"},
{:shards, "~> 1.0"}, #=> When using :shards as backend
{:decorator, "~> 1.4"}, #=> When using Caching Annotations
{:telemetry, "~> 1.0"} #=> When using the Telemetry events (Nebulex stats)
Expand Down
4 changes: 1 addition & 3 deletions lib/mix/tasks/nbx.gen.cache.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule Mix.Tasks.Nbx.Gen.Cache do
Besides, you can also specify the adapter you want to use, like so:
mix nbx.gen.cache -c MyApp.PartitionedCache -a Nebulex.Adapters.Local
mix nbx.gen.cache -c MyApp.LocalCache -a Nebulex.Adapters.Local
mix nbx.gen.cache -c MyApp.PartitionedCache -a Nebulex.Adapters.Partitioned
mix nbx.gen.cache -c MyApp.ReplicatedCache -a Nebulex.Adapters.Replicated
mix nbx.gen.cache -c MyApp.MultilevelCache -a Nebulex.Adapters.Multilevel
Expand Down Expand Up @@ -83,8 +83,6 @@ defmodule Mix.Tasks.Nbx.Gen.Cache do
{#{inspect(cache)}, []}
And for more information about configuration options, check
adapters documentation and Nebulex.Cache shared options.
""")
end

Expand Down
12 changes: 3 additions & 9 deletions lib/nebulex/adapters/local/backend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,21 @@ defmodule Nebulex.Adapters.Local.Backend do
Helper function for returning the child spec for the given backend.
"""
def child_spec(backend, opts) do
backend
|> get_mod()
|> apply(:child_spec, [opts])
get_mod(backend).child_spec(opts)
end

@doc """
Helper function for creating a new table for the given backend.
"""
def new(backend, meta_tab, tab_opts) do
backend
|> get_mod()
|> apply(:new, [meta_tab, tab_opts])
get_mod(backend).new(meta_tab, tab_opts)
end

@doc """
Helper function for deleting a table for the given backend.
"""
def delete(backend, meta_tab, gen_tab) do
backend
|> get_mod()
|> apply(:delete, [meta_tab, gen_tab])
get_mod(backend).delete(meta_tab, gen_tab)
end

defp get_mod(:ets), do: Nebulex.Adapters.Local.Backend.ETS
Expand Down
8 changes: 5 additions & 3 deletions lib/nebulex/adapters/multilevel.ex
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,12 @@ defmodule Nebulex.Adapters.Multilevel do
@impl true
defspan get(adapter_meta, key, opts) do
fun = fn level, {default, prev} ->
if value = with_dynamic_cache(level, :get, [key, opts]) do
{:halt, {value, [level | prev]}}
else
value = with_dynamic_cache(level, :get, [key, opts])

if is_nil(value) do
{:cont, {default, [level | prev]}}
else
{:halt, {value, [level | prev]}}
end
end

Expand Down
Loading

0 comments on commit e80690c

Please sign in to comment.