PayDayLoan.LoadState (pay_day_loan v0.7.0)
Keeps track of which keys are loaded, requested, and loading
Acts as a state tracker and a queue for the loader.
You shouldn't need to call any of these functions manually but they can be useful for debugging.
Link to this section Summary
Functions
Returns all elements of the table
Returns true if any keys are in the :requested
or :reload
states
Set state to :failed
Set state to :loaded
Set state to :loading
Return load state without modifying; return nil if key is not found
Set the load state to :requested
if not loaded or loading,
return the load state
Set the state to :reload
Return the list of keys in the :reload
state, limited to limit
elements
Set state to :reload_loading
Set state to :requested
Set the state to :reload
if the key is loaded, set it to :request
if it
is not
Return the list of requested keys, limited to limit
elements
Remove a key from the load state table
Link to this section Types
@type t() :: :requested | :reload | :loading | :loaded | :failed | :reload_loading
Load states that a key can have.
:requested
- A load has been requested. The load worker should pick this up and set the state to:loading
.:reload
- A value is available and a reload has been requested.:loading
- The load worker is in the process of loading this key.:reload_loading
- The load worker is in the process of loading this key, but it is already loaded and will not block.:loaded
- The key is loaded in cache.:failed
- The key attempted a load or refresh and failed.
Link to this section Functions
all(ets_table_id)
@spec all(atom()) :: [{PayDayLoan.key(), t()}]
Returns all elements of the table
any_requested?(ets_table_id)
Returns true if any keys are in the :requested
or :reload
states
failed(ets_table_id, keys)
@spec failed(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :failed | [:failed]
Set state to :failed
loaded(ets_table_id, keys)
@spec loaded(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :loaded | [:loaded]
Set state to :loaded
loading(ets_table_id, keys)
@spec loading(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :loading | [:loading]
Set state to :loading
peek(ets_table_id, keys)
@spec peek(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: t() | nil | [t() | nil]
Return load state without modifying; return nil if key is not found
query(ets_table_id, keys)
@spec query(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: t() | [t()]
Set the load state to :requested
if not loaded or loading,
return the load state
reload(ets_table_id, keys)
@spec reload(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :reload | [:reload]
Set the state to :reload
reload_keys(ets_table_id, limit)
@spec reload_keys(atom(), pos_integer()) :: [PayDayLoan.key()]
Return the list of keys in the :reload
state, limited to limit
elements
reload_loading(ets_table_id, keys)
@spec reload_loading(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :reload_loading | [:reload_loading]
Set state to :reload_loading
request(ets_table_id, keys)
@spec request(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :requested | [:requested]
Set state to :requested
request_or_reload(ets_table_id, keys)
@spec request_or_reload(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :request | :reload | [:request | :reload]
Set the state to :reload
if the key is loaded, set it to :request
if it
is not
requested_keys(ets_table_id, limit)
@spec requested_keys(atom(), pos_integer()) :: [PayDayLoan.key()]
Return the list of requested keys, limited to limit
elements
unload(ets_table_id, keys)
@spec unload(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :ok | [:ok]
Remove a key from the load state table