Skip to content

Conversation

@arcanemachine
Copy link
Contributor

@arcanemachine arcanemachine commented Jul 19, 2025

These functions both define a return type of {status, boolean}:

  @spec put(Cachex.t(), any, any, Keyword.t()) :: {status, boolean}
  def put(cache, key, value, options \\ []) when is_list(options),

  # ...

  @spec put_many(Cachex.t(), [{any, any}], Keyword.t()) :: {status, boolean}
  def put_many(cache, pairs, options \\ [])

However, both functions may return a non-boolean value as the second element in the tuple, e.g. when an invalid cache name is given:

 iex> Cachex.put(:hello, :world, :ok)
{:error, :no_cache}
 iex> Cachex.put_many(:hello, [{:world, :ok}])
{:error, :no_cache}

This pull requests loosens the return type for these functions to use {status, any}.

These functions both define a return type of `{status, boolean}`, but both may return e.g. `{:error, :no_cache}`, such as when an invalid cache name is given:

```
 iex> Cachex.put(:hello, :world, :ok)
{:error, :no_cache}
```

```
 iex> Cachex.put_many(:hello, [{:world, :ok}])
{:error, :no_cache}
```

This pull requests loosens the return type a bit to use `{status, any}`.
@whitfin whitfin merged commit bd61e33 into whitfin:main Jul 21, 2025
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants