(session: &RespSession, state: &SharedState)
| 396 | // --------------------------------------------------------------------------- |
| 397 | |
| 398 | async fn handle_dbsize(session: &RespSession, state: &SharedState) -> RespValue { |
| 399 | let plan = PhysicalPlan::Kv(KvOp::Scan { |
| 400 | collection: session.collection.clone(), |
| 401 | cursor: Vec::new(), |
| 402 | count: 0, |
| 403 | filters: Vec::new(), |
| 404 | match_pattern: None, |
| 405 | sort_keys: Vec::new(), |
| 406 | surrogate_ceiling: None, |
| 407 | }); |
| 408 | |
| 409 | match dispatch_kv(state, session, plan).await { |
| 410 | Ok(resp) if resp.status == Status::Ok => { |
| 411 | let json: serde_json::Value = match sonic_rs::from_slice(&resp.payload) { |
| 412 | Ok(v) => v, |
| 413 | Err(e) => { |
| 414 | tracing::warn!(error = %e, "RESP DBSIZE: failed to decode KV scan payload"); |
| 415 | return RespValue::err(format!("ERR dbsize decode failed: {e}")); |
| 416 | } |
| 417 | }; |
| 418 | let count = match &json { |
| 419 | serde_json::Value::Array(arr) => arr.len() as i64, |
| 420 | _ => 0, |
| 421 | }; |
| 422 | RespValue::integer(count) |
| 423 | } |
| 424 | _ => RespValue::integer(0), |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | async fn handle_info(_cmd: &RespCommand, session: &RespSession, _state: &SharedState) -> RespValue { |
| 429 | let info = format!( |
no test coverage detected