diff options
-rw-r--r-- | assessments/semiprimes/server/lib/cache.ex | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/assessments/semiprimes/server/lib/cache.ex b/assessments/semiprimes/server/lib/cache.ex index 334bf901b6e6..cd064cc1ae4b 100644 --- a/assessments/semiprimes/server/lib/cache.ex +++ b/assessments/semiprimes/server/lib/cache.ex @@ -24,4 +24,18 @@ defmodule Cache do def put(key, value) do Agent.update(__MODULE__, &Map.put(&1, key, value)) end + + @doc """ + List the contents of the cache. Useful for debugging purposes. + """ + def list() do + Agent.get(__MODULE__, & &1) + end + + @doc """ + Invalidate the entire cache. + """ + def clear() do + Agent.update(__MODULE__, fn _ -> %{} end) + end end |