use redis::{AsyncCommands, FromRedisValue, ToRedisArgs, ToSingleRedisArg}; use crate::error::{CacheError, CacheResult}; use crate::kv::Cache; impl Cache { pub async fn zadd( &self, key: &str, member: M, score: S, ) -> CacheResult { let mut conn = self.conn().clone(); conn.zadd(key, member, score) .await .map_err(CacheError::from) } pub async fn zrem( &self, key: &str, members: M, ) -> CacheResult { let mut conn = self.conn().clone(); conn.zrem(key, members).await.map_err(CacheError::from) } pub async fn zscore( &self, key: &str, member: M, ) -> CacheResult> { let mut conn = self.conn().clone(); conn.zscore(key, member).await.map_err(CacheError::from) } pub async fn zincr( &self, key: &str, member: M, delta: f64, ) -> CacheResult { let mut conn = self.conn().clone(); conn.zincr(key, member, delta) .await .map_err(CacheError::from) } pub async fn zcard(&self, key: &str) -> CacheResult { let mut conn = self.conn().clone(); conn.zcard(key).await.map_err(CacheError::from) } pub async fn zcount( &self, key: &str, min: M, max: MM, ) -> CacheResult { let mut conn = self.conn().clone(); conn.zcount(key, min, max).await.map_err(CacheError::from) } pub async fn zrange( &self, key: &str, start: isize, stop: isize, ) -> CacheResult> { let mut conn = self.conn().clone(); conn.zrange(key, start, stop) .await .map_err(CacheError::from) } pub async fn zrange_withscores( &self, key: &str, start: isize, stop: isize, ) -> CacheResult> { let mut conn = self.conn().clone(); conn.zrange_withscores(key, start, stop) .await .map_err(CacheError::from) } pub async fn zrevrange( &self, key: &str, start: isize, stop: isize, ) -> CacheResult> { let mut conn = self.conn().clone(); conn.zrevrange(key, start, stop) .await .map_err(CacheError::from) } pub async fn zrevrange_withscores( &self, key: &str, start: isize, stop: isize, ) -> CacheResult> { let mut conn = self.conn().clone(); conn.zrevrange_withscores(key, start, stop) .await .map_err(CacheError::from) } pub async fn zrangebyscore< T: FromRedisValue + Send, M: ToSingleRedisArg + Send + Sync, MM: ToSingleRedisArg + Send + Sync, >( &self, key: &str, min: M, max: MM, ) -> CacheResult> { let mut conn = self.conn().clone(); conn.zrangebyscore(key, min, max) .await .map_err(CacheError::from) } pub async fn zrangebyscore_withscores< T: FromRedisValue + Send, M: ToSingleRedisArg + Send + Sync, MM: ToSingleRedisArg + Send + Sync, >( &self, key: &str, min: M, max: MM, ) -> CacheResult> { let mut conn = self.conn().clone(); conn.zrangebyscore_withscores(key, min, max) .await .map_err(CacheError::from) } pub async fn zrank( &self, key: &str, member: M, ) -> CacheResult> { let mut conn = self.conn().clone(); conn.zrank(key, member).await.map_err(CacheError::from) } pub async fn zrevrank( &self, key: &str, member: M, ) -> CacheResult> { let mut conn = self.conn().clone(); conn.zrevrank(key, member).await.map_err(CacheError::from) } }