PayDayLoan.LoadState (pay_day_loan v0.8.2)

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

Types

t()

Load states that a key can have.

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 the list of keys in the :loading state

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

Return the list of keys in the :reload_loading state

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

Link to this function

all(ets_table_id)

@spec all(atom()) :: [{PayDayLoan.key(), t()}]

Returns all elements of the table

Link to this function

any_requested?(ets_table_id)

@spec any_requested?(atom()) :: boolean()

Returns true if any keys are in the :requested or :reload states

Link to this function

failed(ets_table_id, keys)

@spec failed(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :failed | [:failed]

Set state to :failed

Link to this function

loaded(ets_table_id, keys)

@spec loaded(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :loaded | [:loaded]

Set state to :loaded

Link to this function

loading(ets_table_id, keys)

@spec loading(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :loading | [:loading]

Set state to :loading

Link to this function

loading_keys(ets_table_id)

@spec loading_keys(atom() | :ets.tid()) :: [PayDayLoan.key()]

Return the list of keys in the :loading state

Link to this function

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

Link to this function

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

Link to this function

reload(ets_table_id, keys)

@spec reload(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :reload | [:reload]

Set the state to :reload

Link to this function

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

Link to this function

reload_loading(ets_table_id, keys)

@spec reload_loading(atom(), PayDayLoan.key() | [PayDayLoan.key()]) ::
  :reload_loading | [:reload_loading]

Set state to :reload_loading

Link to this function

reload_loading_keys(ets_table_id)

@spec reload_loading_keys(atom() | :ets.tid()) :: [PayDayLoan.key()]

Return the list of keys in the :reload_loading state

Link to this function

request(ets_table_id, keys)

@spec request(atom(), PayDayLoan.key() | [PayDayLoan.key()]) ::
  :requested | [:requested]

Set state to :requested

Link to this function

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

Link to this function

requested_keys(ets_table_id, limit)

@spec requested_keys(atom(), pos_integer()) :: [PayDayLoan.key()]

Return the list of requested keys, limited to limit elements

Link to this function

unload(ets_table_id, keys)

@spec unload(atom(), PayDayLoan.key() | [PayDayLoan.key()]) :: :ok | [:ok]

Remove a key from the load state table