Skip to content

Commit a95b0b4

Browse files
committed
docs: improve docs and guides
Fix examples and claims that no longer match the code (callback arities in the adapter guide, return values, event types, option lists) and drop the marketing tone across the module docs, guides, and README.
1 parent 504e55d commit a95b0b4

29 files changed

Lines changed: 1551 additions & 1588 deletions

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
5555
`use Nebulex.Cache` now validates at compile time that the adapter lists
5656
`Nebulex.Adapter`, `Nebulex.Adapter.KV`, and `Nebulex.Adapter.CompositeKV`
5757
as behaviours. Add `use Nebulex.Adapter.CompositeKV` to an adapter for the
58-
default implementation.
58+
default implementation. The compile-time error says how to fix it: add
59+
the `use` to the adapter, or upgrade it to a version built for v3.1.
5960
[#254](https://github.com/elixir-nebulex/nebulex/issues/254).
6061
- [Nebulex.Cache] `get_and_update/3` no longer treats a `nil` new value as
6162
"do not write". A function returning `{current, nil}` now stores `nil`

‎README.md‎

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@
1515

1616
## 🚀 About
1717

18-
Nebulex provides support for transparently adding caching to existing
19-
Elixir applications. Like [Ecto][ecto], the caching abstraction allows
20-
consistent use of various caching solutions with minimal impact on your
21-
code.
22-
23-
Nebulex's cache abstraction shields developers from directly interacting with
24-
underlying caching implementations, such as [Redis][redis],
25-
[Memcached][memcached], or other Elixir cache implementations like
26-
[Cachex][cachex]. It also provides out-of-the-box features including
27-
[declarative decorator-based caching][nbx_caching],
18+
Nebulex adds caching to Elixir applications. Like [Ecto][ecto], it is an
19+
abstraction: you use different caching backends through the same API, with
20+
little impact on your code.
21+
22+
You write against the Nebulex API instead of talking to [Redis][redis],
23+
[Memcached][memcached], or an Elixir cache like [Cachex][cachex] directly.
24+
Nebulex also comes with [declarative decorator-based caching][nbx_caching],
2825
[cache usage patterns][cache_patterns], and
29-
[distributed cache topologies][cache_topologies],
30-
among others.
26+
[distributed cache topologies][cache_topologies].
3127

3228
[ecto]: https://github.com/elixir-ecto/ecto
3329
[cachex]: https://github.com/whitfin/cachex
@@ -75,19 +71,17 @@ def deps do
7571
end
7672
```
7773

78-
To provide more flexibility and load only the needed dependencies, Nebulex makes
79-
all dependencies optional, including the adapters. For example:
74+
All dependencies are optional, including the adapters, so you only load what
75+
you need:
8076

81-
* **For enabling [declarative decorator-based caching][nbx_caching]**:
82-
Add `:decorator` to the dependency list (recommended).
77+
* For [declarative decorator-based caching][nbx_caching], add `:decorator`
78+
(recommended).
8379

84-
* **For enabling Telemetry events**: Add `:telemetry` to the dependency list
85-
(recommended). See the [Info API guide][info_api] for monitoring cache stats
86-
and metrics.
80+
* For Telemetry events, add `:telemetry` (recommended). See the
81+
[Info API guide][info_api] for cache stats and metrics.
8782

88-
Then run `mix deps.get` in your shell to fetch the dependencies. If you want to
89-
use another cache adapter, just choose the appropriate dependency from the table
90-
above.
83+
Then run `mix deps.get`. To use another cache adapter, pick its dependency
84+
from the [adapters guide][nbx_adapters].
9185

9286
Finally, in your cache definition, you'll need to specify the `adapter:`
9387
corresponding to the chosen dependency. For the local cache, it would be:
@@ -120,18 +114,14 @@ iex> MyApp.Cache.fetch("foo")
120114
{:ok, "bar"}
121115
```
122116

123-
For more detailed information, see the
124-
[getting started guide][getting_started-rc1] and
125-
[online documentation][hex-docs].
126-
127-
[getting_started-rc1]: https://hexdocs.pm/nebulex/getting-started.html
128-
[hex-docs]: https://hexdocs.pm/nebulex/Nebulex.html
117+
For more details, see the [getting started guide][getting_started] and the
118+
[online documentation][docs].
129119

130120
---
131121

132122
## ⚡ Quick Start Example with Caching Decorators
133123

134-
This example demonstrates how to use Nebulex with Ecto and declarative caching:
124+
This example uses Nebulex with Ecto and declarative caching:
135125

136126
```elixir
137127
# In config/config.exs
@@ -244,14 +234,14 @@ To run only the tests:
244234
$ mix test
245235
```
246236

247-
Additionally, to run all Nebulex checks:
237+
To run all the checks CI runs:
248238

249239
```bash
250240
$ mix precommit
251241
```
252242

253-
The `mix precommit` command will run the tests, coverage, credo, dialyzer,
254-
and more. This is the recommended way to test Nebulex.
243+
The `mix precommit` alias runs the tests, coverage, Credo, Dialyzer, and the
244+
other checks. Run it before opening a pull request.
255245

256246
---
257247

@@ -267,15 +257,14 @@ To run a benchmark test:
267257
$ mix bench
268258
```
269259

270-
> The benchmark uses the `Nebulex.Adapters.Nil` adapter; it is more focused on
271-
> measuring the Nebulex abstraction layer performance rather than a specific
272-
> adapter.
260+
> The benchmark uses the `Nebulex.Adapters.Nil` adapter, so it measures the
261+
> Nebulex abstraction layer, not a specific adapter.
273262
274263
---
275264

276265
## 🤝 Contributing
277266

278-
Contributions to Nebulex are very welcome and appreciated!
267+
Contributions are welcome.
279268

280269
Use the [issue tracker](https://github.com/elixir-nebulex/nebulex/issues)
281270
for bug reports or feature requests. Open a

0 commit comments

Comments
 (0)