Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cabol/nebulex
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.0-rc.1
Choose a base ref
...
head repository: cabol/nebulex
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.0-rc.2
Choose a head ref
  • 6 commits
  • 35 files changed
  • 2 contributors

Commits on Aug 14, 2017

  1. Fixes and enhancements

    cabol committed Aug 14, 2017
    Copy the full SHA
    6a734b0 View commit details

Commits on Aug 17, 2017

  1. Copy the full SHA
    149eaa1 View commit details

Commits on Nov 25, 2017

  1. Add simple benchmarks

    Improve vsn generation – set nil when none vsn generator is configured
    cabol committed Nov 25, 2017
    Copy the full SHA
    2b8dbcc View commit details
  2. Copy the full SHA
    7cb6512 View commit details
  3. [#8] Fix atom exhaustion

    cabol committed Nov 25, 2017
    Copy the full SHA
    c220feb View commit details
  4. Pre-release 1.0.0-rc.2

    cabol committed Nov 25, 2017
    Copy the full SHA
    5dfef2c View commit details
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -11,6 +11,9 @@
/doc
/docs

# Bench files
/bench/snapshots

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

23 changes: 12 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
language: elixir
elixir:
- 1.4.5
- 1.3.4
otp_release:
- 20.0
- 19.3
- 18.3
matrix:
include:
- otp_release: 18.3
elixir: 1.4
- otp_release: 19.3
elixir: 1.4
- otp_release: 20.0
elixir: 1.4
- otp_release: 19.3
elixir: 1.5
- otp_release: 20.0
elixir: 1.5
sudo: false
env:
- MIX_ENV=test
matrix:
exclude:
- elixir: 1.3.4
otp_release: 20.0
before_script:
- epmd -daemon
- mix deps.get --only test
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
# Change Log

## [v1.0.0-rc.2](https://github.com/cabol/nebulex/tree/v1.0.0-rc.2) (2017-10-15)
[Full Changelog](https://github.com/cabol/nebulex/compare/v1.0.0-rc.1...v1.0.0-rc.2)

\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
**Closed issues:**

- Atom exhaustion from generations [\#8](https://github.com/cabol/nebulex/issues/8)
- Custom ttl for every cache record? [\#7](https://github.com/cabol/nebulex/issues/7)
- Update Getting Started guide [\#4](https://github.com/cabol/nebulex/issues/4)
- Add counters support – increments and decrements by a given amount [\#3](https://github.com/cabol/nebulex/issues/3)

**Merged pull requests:**

- replacing Cache.all by Cache.to\_map documentation [\#5](https://github.com/cabol/nebulex/pull/5) ([ferigis](https://github.com/ferigis))

## [v1.0.0-rc.1](https://github.com/cabol/nebulex/tree/v1.0.0-rc.1) (2017-07-30)
**Closed issues:**

- Implement mix task to automate cache generation [\#2](https://github.com/cabol/nebulex/issues/2)



\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
28 changes: 24 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# Nebulex
> **Fast, flexible and powerful cache wrapper for Elixir.**
> ### A fast, flexible and powerful caching library for Elixir.
> – Not only local but also distributed!
[![Build Status](https://travis-ci.org/cabol/nebulex.svg?branch=master)](https://travis-ci.org/cabol/nebulex)
[![Coverage Status](https://coveralls.io/repos/github/cabol/nebulex/badge.svg?branch=master)](https://coveralls.io/github/cabol/nebulex?branch=master)
[![Inline docs](http://inch-ci.org/github/cabol/nebulex.svg)](http://inch-ci.org/github/cabol/nebulex)

## Features

* Simple and fluent API inspired by [Ecto](https://github.com/elixir-ecto/ecto)
* Flexible and pluggable architecture like Ecto – based on [adapter pattern](https://en.wikipedia.org/wiki/Adapter_pattern)
* Built-in adapters
- [Local generational cache](http://hexdocs.pm/nebulex/Nebulex.Adapters.Local.html)
- [Distributed cache](http://hexdocs.pm/nebulex/Nebulex.Adapters.Dist.html)
- [Distributed/Partitioned cache](http://hexdocs.pm/nebulex/Nebulex.Adapters.Dist.html)
- [Multi-level cache](http://hexdocs.pm/nebulex/Nebulex.Adapters.Multilevel.html)
* Support for different cache topologies setup (Partitioned, Near, ...)
* Time-based expiration
* Pre/post execution hooks
* [Pre/post execution hooks](http://hexdocs.pm/nebulex/hooks.html)
* Transactions (key-locking)
* Key versioning – support for [optimistic offline locks](https://martinfowler.com/eaaCatalog/optimisticOfflineLock.html)
* Optional statistics gathering
@@ -27,7 +30,7 @@ Add `nebulex` to your list dependencies in `mix.exs`:

```elixir
def deps do
[{:nebulex, "~> 1.0.0-rc.1"}]
[{:nebulex, "~> 1.0.0-rc.2"}]
end
```

@@ -109,3 +112,20 @@ $ epmd -daemon
```

before running the tests.

## Benchmarks

Simple and/or basic benchmarks were added using [benchfella](https://github.com/alco/benchfella);
to learn more, see the [bench](./bench) directory.

To run the benchmarks:

```
$ mix nebulex.bench
```

## Copyright and License

Copyright (c) 2017, Carlos Bolaños.

Nebulex source code is licensed under the [MIT License](LICENSE).
93 changes: 93 additions & 0 deletions bench/dist_bench.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
defmodule DistBench do
use Benchfella

alias Nebulex.NodeCase
alias Nebulex.TestCache.Dist
alias Nebulex.TestCache.DistLocal, as: Local

setup_all do
{:ok, local} = Local.start_link
{:ok, dist} = Dist.start_link
node_pid_list = NodeCase.start_caches(Node.list(), [Local, Dist])

:ok = Enum.each(1..1000, fn x -> Dist.set(x, x) end)
{:ok, {local, dist, node_pid_list}}
end

teardown_all {local, dist, node_pid_list} do
_ = :timer.sleep(100)
if Process.alive?(local), do: Local.stop(local, 1)
if Process.alive?(dist), do: Dist.stop(dist, 1)
NodeCase.stop_caches(node_pid_list)
end

before_each_bench _ do
key = Enum.random(1..1000)
{:ok, key}
end

bench "get" do
Dist.get(bench_context)
:ok
end

bench "get!" do
Dist.get!(bench_context)
:ok
end

bench "set" do
Dist.set(bench_context, bench_context)
:ok
end

bench "delete" do
Dist.delete(bench_context)
:ok
end

bench "has_key?" do
Dist.has_key?(bench_context)
:ok
end

bench "size" do
Dist.size()
:ok
end

bench "keys" do
Dist.keys()
:ok
end

bench "reduce" do
Dist.reduce({%{}, 0}, &Dist.reducer_fun/2)
:ok
end

bench "to_map" do
Dist.to_map()
:ok
end

bench "pop" do
Dist.pop(bench_context)
:ok
end

bench "get_and_update" do
Dist.get_and_update(:non_existent, &Dist.get_and_update_fun/1)
:ok
end

bench "update" do
Dist.update(:non_existent, 1, &Dist.update_fun/1)
:ok
end

bench "update_counter" do
Dist.update_counter(bench_context, 1)
:ok
end
end
92 changes: 92 additions & 0 deletions bench/local_bench.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
defmodule LocalBench do
use Benchfella

Application.put_env(:nebulex, LocalBench.Cache, [gc_interval: 3600, n_shards: 2])

defmodule Cache do
use Nebulex.Cache, otp_app: :nebulex, adapter: Nebulex.Adapters.Local
end

setup_all do
res = Cache.start_link()
:ok = Enum.each(1..1000, fn x -> Cache.set(x, x) end)
res
end

teardown_all pid do
_ = :timer.sleep(10)
if Process.alive?(pid), do: Cache.stop(pid, 1)
end

before_each_bench _ do
key = Enum.random(1..1000)
{:ok, key}
end

bench "get" do
Cache.get(bench_context)
:ok
end

bench "get!" do
Cache.get!(bench_context)
:ok
end

bench "set" do
Cache.set(bench_context, bench_context)
:ok
end

bench "delete" do
Cache.delete(bench_context)
:ok
end

bench "has_key?" do
Cache.has_key?(bench_context)
:ok
end

bench "size" do
Cache.size()
:ok
end

bench "keys" do
Cache.keys()
:ok
end

bench "reduce" do
Cache.reduce([], fn(r, acc) -> [r | acc] end)
:ok
end

bench "to_map" do
Cache.to_map()
:ok
end

bench "pop" do
Cache.pop(bench_context)
:ok
end

bench "get_and_update" do
Cache.get_and_update(bench_context, fn v ->
if v, do: {v, v}, else: {v, 1}
end)
:ok
end

bench "update" do
Cache.update(bench_context, 1, &(&1))
:ok
end

bench "update_counter" do
Cache.update_counter(bench_context, 1)
:ok
end
end
34 changes: 34 additions & 0 deletions bench/tasks/nebulex.bench.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
defmodule Mix.Tasks.Nebulex.Bench do
@moduledoc """
Runs simple benchmarks for `Nebulex.Cache` operations.
## Examples
mix nebulex.bench
"""

use Mix.Task

@doc false
def run(_args) do
System.cmd("epmd", ["-daemon"])
Mix.Task.run("app.start", [])
:ok = start_nodes()
Mix.Tasks.Bench.run []
end

defp start_nodes() do
required_files =
for file <- File.ls!("./test/support") do
{file, Code.require_file("../../test/support/" <> file, __DIR__)}
end

nodes = Keyword.values(Nebulex.Cluster.spawn())
Enum.each(required_files, fn({file, loaded}) ->
Enum.each(loaded, fn({mod, bin}) ->
expected = List.duplicate({:module, mod}, length(nodes))
{^expected, []} = :rpc.multicall(nodes, :code, :load_binary, [mod, to_char_list(file), bin])
end)
end)
end
end
Loading