Skip to content

Commit 07e00e8

Browse files
committed
document get function in Cache module
1 parent bbc0e1e commit 07e00e8

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

lib/scenic/cache.ex

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,32 @@ defmodule Scenic.Cache do
5252

5353
# ===========================================================================
5454
defmodule Error do
55+
@moduledoc """
56+
Defines the exception thrown by the CacheModule
57+
"""
5558
defexception message: nil
5659
end
5760

58-
# ============================================================================
5961
# client apis
6062

61-
# --------------------------------------------------------
63+
@doc """
64+
This function to collects an item from the Cache.
65+
This function accepts a key and a default both being any term in Elixir.
66+
67+
If there is no item in the Cache that corresponds to the key the function will return nil else the
68+
function returns the term stored in the cache with the using the provided key
69+
70+
## Examples
71+
72+
iex> Scenic.Cache.get("test_key")
73+
nil
74+
75+
iex> :ets.insert(:scenic_cache_key_table, {"test_key", 1, :test_data})
76+
...> true
77+
...> Scenic.Cache.get("test_key")
78+
:test_data
79+
"""
80+
@spec get(term(), term()) :: term() | nil
6281
def get(key, default \\ nil)
6382

6483
def get(key, default) do
@@ -71,7 +90,6 @@ defmodule Scenic.Cache do
7190
reraise(other, __STACKTRACE__)
7291
end
7392

74-
# --------------------------------------------------------
7593
def fetch(key)
7694

7795
def fetch(key) do

0 commit comments

Comments
 (0)