forked from nameinmaking/memory
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
William Guo
authored and
William Guo
committed
Feb 13, 2018
1 parent
4a31298
commit 1a65ffa
Showing
3 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule Memory.GameBackup do | ||
use Agent | ||
|
||
def start_link do | ||
Agent.start_link(fn -> %{} end, name: __MODULE__) | ||
end | ||
|
||
def save(name, game) do | ||
Agent.update(__MODULE__, fn state -> | ||
Map.put(state, name, game) | ||
end) | ||
end | ||
|
||
def load(name) do | ||
Agent.get(__MODULE__, fn state -> | ||
Map.get(state, name) | ||
end) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters