@@ -566,25 +566,25 @@ defmodule Cachex do
566
566
to lazily generate a value on cache miss. Conceptually similar to a
567
567
read-through cache.
568
568
569
- Cachex will store any value `fallback` returns . If you want more
569
+ Normally Cache stores the value returned by `fallback`. If you want more
570
570
control, return a Tuple like `{:commit, value}` or `{:ignore, value}`.
571
- Passing `:ignore` instructs Cachex to not store the value.
571
+ Passing `:ignore` instructs Cachex not to store the value.
572
572
573
573
You may provide a third element in a `:commit` Tuple, to specify options the
574
574
same as you would in `put/4`.
575
575
576
+ `fallback` optionally takes argument `key`.
577
+
576
578
Multiple calls to `fetch/4` with the same key while the `fallback` is running
577
579
will wait on the lazy evaluation to complete. Multiple instances of
578
580
`fallback` will never run concurrently for a given key.
579
581
580
- `fallback` optionally receives `key` as an argument.
581
-
582
582
## Examples
583
583
584
- iex> Cachex.fetch(:my_cache, "key", fn -> "default " end)
585
- { :commit, "default " }
586
- iex> Cachex.fetch(:my_cache, "key", fn -> "default " end)
587
- { :ok, "default " }
584
+ iex> Cachex.fetch(:my_cache, "key", fn -> "value " end)
585
+ { :commit, "value " }
586
+ iex> Cachex.fetch(:my_cache, "key", fn -> "value " end)
587
+ { :ok, "value " }
588
588
589
589
iex> Cachex.fetch(:my_cache, "missing_key", fn(key) ->
590
590
...> { :ignore, String.reverse(key) }
0 commit comments