Skip to content

Commit

Permalink
Reapply mix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
whitfin committed Mar 11, 2024
1 parent b7dc0be commit 9035ec0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
7 changes: 2 additions & 5 deletions lib/cachex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ defmodule Cachex do
"""
@spec start(atom, Keyword.t()) :: {atom, pid}
def start(name, options \\ []) do
with {:ok, pid} <- start_link(name, options),
true <- :erlang.unlink(pid) do
with {:ok, pid} <- start_link(name, options), true <- :erlang.unlink(pid) do
{:ok, pid}
end
end
Expand All @@ -339,9 +338,7 @@ defmodule Cachex do
# This will start all cache services required using the `Cachex.Services`
# module and attach them under a Supervisor instance backing the cache.
@spec init(cache :: Cachex.Spec.cache()) ::
{:ok,
{Supervisor.sup_flags(),
[Supervisor.child_spec() | (old_erlang_child_spec :: Supervisor.child_spec())]}}
{:ok, {Supervisor.sup_flags(), [Supervisor.child_spec()]}}
def init(cache() = cache) do
cache
|> Services.cache_spec()
Expand Down
2 changes: 1 addition & 1 deletion lib/cachex/actions.ex
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ defmodule Cachex.Actions do
@doc """
Writes a new entry into a cache.
"""
@spec write(Cachex.Spec.cache(), [Cachex.Spec.entry()]) :: {:ok, boolean}
@spec write(Cachex.Spec.cache(), Cachex.Spec.entries()) :: {:ok, boolean}
def write(cache(name: name), entries),
do: {:ok, :ets.insert(name, entries)}

Expand Down
2 changes: 1 addition & 1 deletion lib/cachex/actions/put.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ defmodule Cachex.Actions.Put do
record = entry_now(key: key, ttl: expiry, value: value)

Locksmith.write(cache, [key], fn ->
Actions.write(cache, [record])
Actions.write(cache, record)
end)
end
end
2 changes: 1 addition & 1 deletion lib/cachex/services/courier.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ defmodule Cachex.Services.Courier do
simplify the interfaces internally. This is a blocking remote
call which will wait until a result can be loaded.
"""
@spec dispatch(Cachex.Spec.cache(), any, (() -> any)) :: any
@spec dispatch(Cachex.Spec.cache(), any, (-> any)) :: any
def dispatch(cache() = cache, key, task) when is_function(task, 0),
do: service_call(cache, :courier, {:dispatch, key, task, local_stack()})

Expand Down
4 changes: 2 additions & 2 deletions lib/cachex/services/locksmith.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ defmodule Cachex.Services.Locksmith do
This is mainly shorthand to avoid having to handle row locking explicitly.
"""
@spec transaction(Cachex.Spec.cache(), [any], (() -> any)) :: any
@spec transaction(Cachex.Spec.cache(), [any], (-> any)) :: any
def transaction(cache() = cache, keys, fun) when is_list(keys) do
case transaction?() do
true -> fun.()
Expand Down Expand Up @@ -155,7 +155,7 @@ defmodule Cachex.Services.Locksmith do
transactions executed against it we skip the lock check as any of
our ETS writes are atomic and so do not require a lock.
"""
@spec write(Cachex.Spec.cache(), any, (() -> any)) :: any
@spec write(Cachex.Spec.cache(), any, (-> any)) :: any
def write(cache(transactional: false), _keys, fun),
do: fun.()

Expand Down
4 changes: 2 additions & 2 deletions lib/cachex/services/locksmith/queue.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ defmodule Cachex.Services.Locksmith.Queue do
@doc """
Executes a function in a lock-free context.
"""
@spec execute(Cachex.Spec.cache(), (() -> any)) :: any
@spec execute(Cachex.Spec.cache(), (-> any)) :: any
def execute(cache() = cache, func) when is_function(func, 0),
do: service_call(cache, :locksmith, {:exec, func})

@doc """
Executes a function in a transactional context.
"""
@spec transaction(Cachex.Spec.cache(), [any], (() -> any)) :: any
@spec transaction(Cachex.Spec.cache(), [any], (-> any)) :: any
def transaction(cache() = cache, keys, func)
when is_list(keys) and is_function(func, 0),
do: service_call(cache, :locksmith, {:transaction, keys, func})
Expand Down
2 changes: 1 addition & 1 deletion lib/cachex/services/overseer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ defmodule Cachex.Services.Overseer do
@doc """
Carries out a transaction against the state table.
"""
@spec transaction(atom, (() -> any)) :: any
@spec transaction(atom, (-> any)) :: any
def transaction(name, fun) when is_atom(name) and is_function(fun, 0),
do: :sleeplocks.execute(@manager_name, fun)

Expand Down
3 changes: 3 additions & 0 deletions lib/cachex/spec.ex
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ defmodule Cachex.Spec do
value: any
)

# Helper type for entry types
@type entries :: entry | [entry]

# Record specification for a cache expiration
@type expiration ::
record(:expiration,
Expand Down

0 comments on commit 9035ec0

Please sign in to comment.