feat(redis): edit hash fields
This commit is contained in:
1 parent
75c2dc5e17
commit
0f9d32e1f5
18 files changed
+470
-14
No files matched your search
@@ -588,6 +588,7 @@ async fn main() {
|
||||
.route("/redis/rename-key", post(routes::redis::rename_key))
|
||||
.route("/redis/hash-set", post(routes::redis::hash_set))
|
||||
.route("/redis/hash-del", post(routes::redis::hash_del))
|
||||
.route("/redis/hash-field-update", post(routes::redis::hash_field_update))
|
||||
.route("/redis/hash-field-set-ttl", post(routes::redis::hash_field_set_ttl))
|
||||
.route("/redis/hash-field-set-expire-at", post(routes::redis::hash_field_set_expire_at))
|
||||
.route("/redis/list-push", post(routes::redis::list_push))
|
||||
|
||||
@@ -148,6 +148,17 @@ pub struct RedisHashRequest {
|
||||
pub ttl: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RedisHashFieldUpdateRequest {
|
||||
pub connection_id: String,
|
||||
pub db: u32,
|
||||
pub key_raw: String,
|
||||
pub old_field: String,
|
||||
pub new_field: String,
|
||||
pub value: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RedisHashFieldTtlRequest {
|
||||
@@ -541,6 +552,25 @@ pub async fn hash_del(
|
||||
Ok(Json(()))
|
||||
}
|
||||
|
||||
pub async fn hash_field_update(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<RedisHashFieldUpdateRequest>,
|
||||
) -> Result<Json<()>, AppError> {
|
||||
ensure_writable(&state.app, &req.connection_id, "Atomic hash field update").await?;
|
||||
dbx_core::redis_ops::redis_hash_field_update_in_db_core(
|
||||
&state.app,
|
||||
&req.connection_id,
|
||||
req.db,
|
||||
&req.key_raw,
|
||||
&req.old_field,
|
||||
&req.new_field,
|
||||
&req.value,
|
||||
)
|
||||
.await
|
||||
.map_err(AppError::from)?;
|
||||
Ok(Json(()))
|
||||
}
|
||||
|
||||
pub async fn hash_field_set_ttl(
|
||||
State(state): State<Arc<WebState>>,
|
||||
Json(req): Json<RedisHashFieldTtlRequest>,
|
||||
|
||||
Reference in new issue
Block a user