Current section

Files

Jump to
ecto_struct_cachex lib decorator cache_put.ex
Raw

lib/decorator/cache_put.ex

defmodule ESC.Decorator.CachePut do
@moduledoc false
alias ESC.{Cache, Config}
defmacro __using__(_opts) do
quote do
def cache_put(struct_name, block, %Decorator.Decorate.Context{} = ctx) do
quote do
with(
false = _disable <- Config.get_disable(),
exec_block <- fn -> unquote(block) end,
struct_name <- unquote(struct_name)
) do
Cache.put(struct_name, exec_block)
else
true -> unquote(block)
end
end
end
end
end
end