elixir_leaderboard v0.1.5 ElixirLeaderboard.TermStore View Source

Use this storage engine to make small size one-off leaderboards that are stored entirely in a variable. Useful for leaderboards scoped to small groups of participants.

Link to this section Summary

Functions

Add a single entry to the leaderboard. Return an error if the entry is already in the leaderboard. The operation should be blocking

Atomically insert an entry, or update it if its id already exists in the leaderboard

Return a correctly ordered stream of bottom leaderboard records that can be accessed all the way to the top

Clear all the data in your leaderboard state

Show the number of records in the leaderboard

Create a leaderboard in your storage (keyword arguments are determined by storage needs). Return what needs to be persisted

Return a leaderboard record by its id. Return nil if not found

Return a list of records around the given id. The list should go from top to bottom if the range is increasing, and from bottom to top if range decreasing. Zero always corresponds to where the id is positioned

Replace all data in the leaderboard with the data in the provided stream. Block until completed

Remove a single entry from the leaderboard based on its id. Return an error if the id does not exist. The operation should be blocking

Return a correctly ordered stream of top leaderboard records that can be accessed all the way to the bottom

Update a single entry in the leaderboard. Return an error if the entry is not found in the leaderboard. The operation should be blocking

Link to this section Functions

Link to this function

add(state, entry, indexer) View Source

Add a single entry to the leaderboard. Return an error if the entry is already in the leaderboard. The operation should be blocking.

Callback implementation for ElixirLeaderboard.Storage.add/3.

Link to this function

add_or_update(state, entry, indexer) View Source

Atomically insert an entry, or update it if its id already exists in the leaderboard.

Callback implementation for ElixirLeaderboard.Storage.add_or_update/3.

Return a correctly ordered stream of bottom leaderboard records that can be accessed all the way to the top.

Callback implementation for ElixirLeaderboard.Storage.bottom/1.

Clear all the data in your leaderboard state.

Callback implementation for ElixirLeaderboard.Storage.clear/1.

Show the number of records in the leaderboard.

Callback implementation for ElixirLeaderboard.Storage.count/1.

Create a leaderboard in your storage (keyword arguments are determined by storage needs). Return what needs to be persisted.

Callback implementation for ElixirLeaderboard.Storage.create/1.

Return a leaderboard record by its id. Return nil if not found.

Callback implementation for ElixirLeaderboard.Storage.get/2.

Return a list of records around the given id. The list should go from top to bottom if the range is increasing, and from bottom to top if range decreasing. Zero always corresponds to where the id is positioned.

For example:

  • A range -2..1 should return (from top to bottom) 2 records prior to the given id, the record at the given id, and 1 record after the given id.
  • A range 2..-2 should return (from bottom to top) 2 records after the given id, the record at the given id, and 2 records before the given id.

Callback implementation for ElixirLeaderboard.Storage.get/3.

Link to this function

populate(_, data, indexer) View Source

Replace all data in the leaderboard with the data in the provided stream. Block until completed.

Callback implementation for ElixirLeaderboard.Storage.populate/3.

Link to this function

remove(state, id, indexer) View Source

Remove a single entry from the leaderboard based on its id. Return an error if the id does not exist. The operation should be blocking.

Callback implementation for ElixirLeaderboard.Storage.remove/3.

Return a correctly ordered stream of top leaderboard records that can be accessed all the way to the bottom.

Callback implementation for ElixirLeaderboard.Storage.top/1.

Link to this function

update(state, entry, indexer) View Source

Update a single entry in the leaderboard. Return an error if the entry is not found in the leaderboard. The operation should be blocking.

Callback implementation for ElixirLeaderboard.Storage.update/3.