Skip to content

Commit

Permalink
Update various documentation issues
Browse files Browse the repository at this point in the history
  • Loading branch information
whitfin committed Oct 18, 2024
1 parent 4a4d8d5 commit b1c6cf8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/migrations/migrating-to-v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Cachex.size(:my_cache, expired: false)

This should hopefully feel more intuitive, while allowing us to trim a bunch of the Cachex internals. The underlying implementations are identical, so it should be easy to migrate if you need to.

Both functions `dump/3` and `load/3` have been renamed in Cachex v4. These names were terrible to begin with, so it's about time they're changed! Instead we now have `Cachex.save/3` and `Cachex.restore/3`, which behave in exactly the same way (aside from being a bit cleaner in implementation!).
Both functions `dump/3` and `load/3` have been renamed in Cachex v4. These names were terrible to begin with, so it's about time they're changed! Instead we now have `Cachex.save/3` and `Cachex.restore/3`, which behave in exactly the same way (aside from being a bit cleaner in implementation!). The only major difference here is that `Cachex.restore/3` will return a count of restored documents, rather than simply `true`.

Finally the two deprecated functions `set/4` and `set_many/3` have finally been removed. If you were using these, please use `Cachex.put/4` and `Cachex.put_many/3` instead from now on.

Expand Down
14 changes: 5 additions & 9 deletions lib/cachex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,8 @@ defmodule Cachex do
As of Cachex v3.6, you can also provide a third element in a `:commit`
Tuple, to allow passthrough of options from within your fallback. The
options supported in this list match the options you can provide to a
call of `put/4`. An example is the `:ttl` option to set an expiration
from directly inside your fallback.
call of `Cachex.put/4`. An example is the `:expire` option to set an
expiration from directly inside your fallback.
If a fallback function has an arity of 1, the requested entry key
will be passed through to allow for contextual computation. If a
Expand All @@ -592,10 +592,6 @@ defmodule Cachex do
This is to allow easy state sharing, such as remote clients. If a
function has an arity of 0, it will be executed without arguments.
If a cache has been initialized with a default fallback function
in the `:fallback` option at cache startup, the third argument to
this call becomes optional.
## Examples
iex> Cachex.put(:my_cache, "key", "value")
Expand All @@ -617,7 +613,7 @@ defmodule Cachex do
iex> Cachex.fetch(:my_cache, "missing_key_expires", fn(key) ->
...> { :commit, String.reverse(key), expire: :timer.seconds(60) }
...> end)
{ :commit, "seripxe_yek_gnissim", [expire: 60000] }
{ :commit, "seripxe_yek_gnissim" }
"""
@spec fetch(Cachex.t(), any, function(), Keyword.t()) ::
Expand Down Expand Up @@ -710,7 +706,7 @@ defmodule Cachex do
{ :ok, 1 }
"""
@spec import(Cachex.t(), Enumerable.t(), Keyword.t()) :: {status, any}
@spec import(Cachex.t(), Enumerable.t(), Keyword.t()) :: {status, integer}
def import(cache, entries, options \\ []) when is_list(options),
do: Router.route(cache, {:import, [entries, options]})

Expand Down Expand Up @@ -1099,7 +1095,7 @@ defmodule Cachex do
{ :ok, 1 }
"""
@spec restore(Cachex.t(), binary, Keyword.t()) :: {status, any}
@spec restore(Cachex.t(), binary, Keyword.t()) :: {status, integer}
def restore(cache, path, options \\ [])
when is_binary(path) and is_list(options),
do: Router.route(cache, {:restore, [path, options]})
Expand Down

0 comments on commit b1c6cf8

Please sign in to comment.