Implement SortedSet key-value entry type #154
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 aSortedSet
. Equivalent todb.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. ReturnsOption<Score>
.increment_by(Value, Score).await
: Increments the score for the value by the score passed in. Returns the newScore
.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.