object: add Object.prune()
This commit is contained in:
parent
be6b57193a
commit
c2b0b82e6a
1 changed files with 7 additions and 0 deletions
|
@ -130,6 +130,13 @@ def delete(%Object{data: %{"id" => id}} = object) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def prune(%Object{data: %{"id" => id}} = object) do
|
||||||
|
with {:ok, object} <- Repo.delete(object),
|
||||||
|
{:ok, true} <- Cachex.del(:object_cache, "object:#{id}") do
|
||||||
|
{:ok, object}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def set_cache(%Object{data: %{"id" => ap_id}} = object) do
|
def set_cache(%Object{data: %{"id" => ap_id}} = object) do
|
||||||
Cachex.put(:object_cache, "object:#{ap_id}", object)
|
Cachex.put(:object_cache, "object:#{ap_id}", object)
|
||||||
{:ok, object}
|
{:ok, object}
|
||||||
|
|
Loading…
Reference in a new issue