Skip to content

Commit

Permalink
adjust json_get and json_set in sandbox (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
CorneliaKelinske committed May 26, 2023
1 parent c360822 commit fc07e27
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/cache/sandbox.ex
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ defmodule Cache.Sandbox do
end

def json_get(cache_name, key, path, _opts) do
Agent.update(cache_name, fn state ->
Map.update(state, key, nil, &get_in(&1, String.split(path, ".")))
Agent.get(cache_name, fn state ->
{:ok, get_in(state, [key, String.split(path, ".")])}
end)
end

def json_set(cache_name, key, path, value, _opts) do
Agent.update(cache_name, fn state ->
Map.update(state, key, nil, &put_in(&1, String.split(path, "."), value))
Map.put(state, key, put_in(state, [String.split(path, ".")], value))
end)
end

Expand Down

0 comments on commit fc07e27

Please sign in to comment.