Skip to content

Conversation

@ecton
Copy link
Member

@ecton ecton commented Jan 26, 2022

Closes #145

Proposed API

Sorted Set Entrypoint:

  • db.sorted_set("key"): Returns a builder.

Functions available on the sorted-set builder when no range has been provided:

  • .await: Returns the entire sorted set as a SortedSet. Equivalent to db.get_get("key").into().await
  • .range(impl RangeBounds<Score>): Returns a new builder instance that has a range, changing the APIs that are available.
  • insert(Value, Score).await: Inserts a new entry. Returns Option<Score>.
  • increment_by(Value, Score).await: Increments the score for the value by the score passed in. Returns the new Score.
  • decrement_by(Value, Score).await: Same as above but decrement.
  • score(Value).await: Returns the score for the value. Option<Score>
  • index_of(Value).await: Returns the index of the value as sorted by the scores. Option<u64>.
  • delete(Value).await: Deletes the value. Returns the score if one existed: Option<Score>.

Functions available on the sorted-set builder with or without a range provided:

  • values().await: Returns only the values: Vec<Value>
  • scores().await: Returns only the scores: Vec<Score>
  • count().await: Returns the number of value: u64
  • pop_front().await: Removes and returns the first value/score pair combination: Option<(Value, Score)>.
  • pop_back().await: Removes and returns the last value/score pair combination: Option<(Value, Score)>.
  • clear().await: Deletes the matching values.

Need to design an API to expose it, but this functionality should be all
that's needed for the initial implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement "Sorted Sets" for the Key-Value store

1 participant