-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Using Pockets to use DETS instead of ETS. #1
- Loading branch information
1 parent
555dbee
commit ab8c2b7
Showing
6 changed files
with
27 additions
and
60 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,4 +72,5 @@ npm-debug.log | |
/assets/node_modules/ | ||
|
||
# Env files | ||
.env | ||
.env | ||
cache.dets |
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
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 |
---|---|---|
@@ -1,35 +1,19 @@ | ||
defmodule UsersTable do | ||
|
||
alias ETS.Set | ||
alias Pockets | ||
|
||
@table :users_table | ||
|
||
def init do | ||
Set.new(name: @table) | ||
Pockets.new(@table, "cache.dets") | ||
end | ||
|
||
def list_users do | ||
@table | ||
|> Set.wrap_existing!() | ||
|> Set.to_list() | ||
Pockets.to_map(@table) | ||
end | ||
|
||
def create_user(%{:stripe_id => stripe_id, :person_id => person_id}) do | ||
@table | ||
|> Set.wrap_existing!() | ||
|> Set.put_new( {person_id, stripe_id, false}) | ||
end | ||
|
||
def update_payment_status(%{:person_id => person_id, :status => new_status}) do | ||
|
||
set = @table | ||
|> Set.wrap_existing!() | ||
|
||
{person_id, stripe_id, _status} = set | ||
|> Set.get!(person_id) | ||
|
||
set | ||
|> Set.put({person_id, stripe_id, new_status}) | ||
def create_user(%{:stripe_id => stripe_id, :person_id => person_id, :status => status}) do | ||
Pockets.put(@table, person_id, %{stripe_id: stripe_id, status: status}) | ||
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
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