Created
June 13, 2017 18:02
-
-
Save FabienHenon/15ef474a539a0871188aa2775b134e3a to your computer and use it in GitHub Desktop.
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
defmodule Redis do | |
@name {:global, :redis} | |
def start_link do | |
Agent.start_link(&Map.new/0, name: @name) | |
end | |
def set(key, value) do | |
Agent.update(@name, &Map.put(&1, key, value)) | |
end | |
def get(key) do | |
Agent.get(@name, &Map.get(&1, key)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment