pub struct SortedSetManager { /* private fields */ }Expand description
Sorted Set data structure interface (Redis-compatible)
Provides scored, ordered collections with ranking and range query capabilities.
Implementations§
Source§impl SortedSetManager
impl SortedSetManager
Sourcepub async fn add<K, M>(&self, key: K, member: M, score: f64) -> Result<bool>
pub async fn add<K, M>(&self, key: K, member: M, score: f64) -> Result<bool>
Add member with score to sorted set (ZADD)
§Example
client.sorted_set().add("leaderboard", "player1", 100.0).await?;Sourcepub async fn add_multiple<K>(
&self,
key: K,
members: Vec<ScoredMember>,
) -> Result<usize>
pub async fn add_multiple<K>( &self, key: K, members: Vec<ScoredMember>, ) -> Result<usize>
Add multiple members with scores to sorted set (ZADD with array)
§Example
let members = vec![
ScoredMember { member: "player1".to_string(), score: 100.0 },
ScoredMember { member: "player2".to_string(), score: 200.0 },
];
client.sorted_set().add_multiple("leaderboard", members).await?;Sourcepub async fn rem<K>(&self, key: K, members: Vec<String>) -> Result<usize>
pub async fn rem<K>(&self, key: K, members: Vec<String>) -> Result<usize>
Remove members from sorted set (ZREM)
Sourcepub async fn score<K, M>(&self, key: K, member: M) -> Result<Option<f64>>
pub async fn score<K, M>(&self, key: K, member: M) -> Result<Option<f64>>
Get score of a member (ZSCORE)
Sourcepub async fn card<K>(&self, key: K) -> Result<usize>
pub async fn card<K>(&self, key: K) -> Result<usize>
Get cardinality (number of members) (ZCARD)
Sourcepub async fn incr_by<K, M>(
&self,
key: K,
member: M,
increment: f64,
) -> Result<f64>
pub async fn incr_by<K, M>( &self, key: K, member: M, increment: f64, ) -> Result<f64>
Increment score of member (ZINCRBY)
Sourcepub async fn range<K>(
&self,
key: K,
start: i64,
stop: i64,
with_scores: bool,
) -> Result<Vec<ScoredMember>>
pub async fn range<K>( &self, key: K, start: i64, stop: i64, with_scores: bool, ) -> Result<Vec<ScoredMember>>
Get range by rank (0-based index) (ZRANGE)
§Example
// Get top 10 from leaderboard
let top10 = client.sorted_set().range("leaderboard", 0, 9, true).await?;
for member in top10 {
tracing::info!("{}: {}", member.member, member.score);
}Sourcepub async fn rev_range<K>(
&self,
key: K,
start: i64,
stop: i64,
with_scores: bool,
) -> Result<Vec<ScoredMember>>
pub async fn rev_range<K>( &self, key: K, start: i64, stop: i64, with_scores: bool, ) -> Result<Vec<ScoredMember>>
Get reverse range by rank (highest to lowest) (ZREVRANGE)
Sourcepub async fn rank<K, M>(&self, key: K, member: M) -> Result<Option<usize>>
pub async fn rank<K, M>(&self, key: K, member: M) -> Result<Option<usize>>
Get rank of member (0-based, lowest score = rank 0) (ZRANK)
Sourcepub async fn rev_rank<K, M>(&self, key: K, member: M) -> Result<Option<usize>>
pub async fn rev_rank<K, M>(&self, key: K, member: M) -> Result<Option<usize>>
Get reverse rank of member (0-based, highest score = rank 0) (ZREVRANK)
Sourcepub async fn count<K>(&self, key: K, min: f64, max: f64) -> Result<usize>
pub async fn count<K>(&self, key: K, min: f64, max: f64) -> Result<usize>
Count members with scores in range (ZCOUNT)
Sourcepub async fn range_by_score<K>(
&self,
key: K,
min: f64,
max: f64,
with_scores: bool,
) -> Result<Vec<ScoredMember>>
pub async fn range_by_score<K>( &self, key: K, min: f64, max: f64, with_scores: bool, ) -> Result<Vec<ScoredMember>>
Get range by score (ZRANGEBYSCORE)
Sourcepub async fn pop_min<K>(
&self,
key: K,
count: usize,
) -> Result<Vec<ScoredMember>>
pub async fn pop_min<K>( &self, key: K, count: usize, ) -> Result<Vec<ScoredMember>>
Pop minimum scored members (ZPOPMIN)
Sourcepub async fn pop_max<K>(
&self,
key: K,
count: usize,
) -> Result<Vec<ScoredMember>>
pub async fn pop_max<K>( &self, key: K, count: usize, ) -> Result<Vec<ScoredMember>>
Pop maximum scored members (ZPOPMAX)
Sourcepub async fn rem_range_by_rank<K>(
&self,
key: K,
start: i64,
stop: i64,
) -> Result<usize>
pub async fn rem_range_by_rank<K>( &self, key: K, start: i64, stop: i64, ) -> Result<usize>
Remove members by rank range (ZREMRANGEBYRANK)
Sourcepub async fn rem_range_by_score<K>(
&self,
key: K,
min: f64,
max: f64,
) -> Result<usize>
pub async fn rem_range_by_score<K>( &self, key: K, min: f64, max: f64, ) -> Result<usize>
Remove members by score range (ZREMRANGEBYSCORE)
Sourcepub async fn inter_store<D>(
&self,
destination: D,
keys: Vec<&str>,
weights: Option<Vec<f64>>,
aggregate: &str,
) -> Result<usize>
pub async fn inter_store<D>( &self, destination: D, keys: Vec<&str>, weights: Option<Vec<f64>>, aggregate: &str, ) -> Result<usize>
Compute intersection and store in destination (ZINTERSTORE)
§Example
// Intersect two leaderboards
let count = client.sorted_set().inter_store(
"combined",
vec!["board1", "board2"],
None,
"sum",
).await?;Sourcepub async fn union_store<D>(
&self,
destination: D,
keys: Vec<&str>,
weights: Option<Vec<f64>>,
aggregate: &str,
) -> Result<usize>
pub async fn union_store<D>( &self, destination: D, keys: Vec<&str>, weights: Option<Vec<f64>>, aggregate: &str, ) -> Result<usize>
Compute union and store in destination (ZUNIONSTORE)
Sourcepub async fn diff_store<D>(
&self,
destination: D,
keys: Vec<&str>,
) -> Result<usize>
pub async fn diff_store<D>( &self, destination: D, keys: Vec<&str>, ) -> Result<usize>
Compute difference and store in destination (ZDIFFSTORE)
Sourcepub async fn stats(&self) -> Result<SortedSetStats>
pub async fn stats(&self) -> Result<SortedSetStats>
Get statistics
Trait Implementations§
Source§impl Clone for SortedSetManager
impl Clone for SortedSetManager
Source§fn clone(&self) -> SortedSetManager
fn clone(&self) -> SortedSetManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more