feat(redis): support score sorting and inline sorted-set editing

This commit is contained in:
二丫讲梵 authored and GitHub committed 2026-08-05 09:46:18 +08:00
1 parent 2c91cdaba3
commit ffaede31b9
20 files changed
+621 -102

No files matched your search

+1
View File
@@ -512,6 +512,7 @@ async fn main() {
.route("/redis/set-add", post(routes::redis::set_add))
.route("/redis/set-remove", post(routes::redis::set_remove))
.route("/redis/zadd", post(routes::redis::zadd))
.route("/redis/zset-update", post(routes::redis::zset_update))
.route("/redis/stream-add", post(routes::redis::stream_add))
.route("/redis/json-set", post(routes::redis::json_set))
.route("/redis/check-json-module", post(routes::redis::check_json_module))
+34
View File
@@ -115,6 +115,7 @@ pub struct RedisLoadMoreRequest {
pub cursor: u64,
pub count: usize,
pub filter: Option<String>,
pub sort_direction: Option<String>,
}
#[derive(Deserialize)]
@@ -149,6 +150,18 @@ pub struct RedisZaddRequest {
pub ttl: Option<i64>,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RedisZsetUpdateRequest {
pub connection_id: String,
pub db: u32,
pub key_raw: String,
pub original_member: String,
pub expected_score: String,
pub member: String,
pub score: String,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RedisListRequest {
@@ -415,6 +428,7 @@ pub async fn load_more(
req.cursor,
req.count,
req.filter.as_deref(),
req.sort_direction.as_deref(),
)
.await
.map_err(AppError::from)?;
@@ -570,6 +584,26 @@ pub async fn zadd(State(state): State<Arc<WebState>>, Json(req): Json<RedisZaddR
Ok(Json(()))
}
pub async fn zset_update(
State(state): State<Arc<WebState>>,
Json(req): Json<RedisZsetUpdateRequest>,
) -> Result<Json<bool>, AppError> {
ensure_writable(&state.app, &req.connection_id, "ZADD/ZREM").await?;
let used_acl_compatibility = dbx_core::redis_ops::redis_zset_update_in_db_core(
&state.app,
&req.connection_id,
req.db,
&req.key_raw,
&req.original_member,
&req.expected_score,
&req.member,
&req.score,
)
.await
.map_err(AppError::from)?;
Ok(Json(used_acl_compatibility))
}
pub async fn stream_add(
State(state): State<Arc<WebState>>,
Json(req): Json<RedisStreamAddRequest>,