diff options
author | William Carroll <wpcarro@gmail.com> | 2020-12-12T01·31+0000 |
---|---|---|
committer | William Carroll <wpcarro@gmail.com> | 2020-12-12T01·31+0000 |
commit | ab732202808e175eb6ae670687280b8f4dbaf1e8 (patch) | |
tree | 7503b5852091abc28a8399bf2609b58067e8311f | |
parent | 714ec29743bd90257ed7607635abe885df01267d (diff) |
Define Cache.{list,clear} to help debugging
Since I'm often using `iex` for interactive development, these functions are useful.
-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 |