it works
This commit is contained in:
36
src/cmd.rs
36
src/cmd.rs
@@ -484,10 +484,7 @@ impl Cmd {
|
||||
Cmd::LIndex(key, index) => lindex_cmd(server, &key, index).await,
|
||||
Cmd::LRange(key, start, stop) => lrange_cmd(server, &key, start, stop).await,
|
||||
Cmd::FlushDb => flushdb_cmd(server).await,
|
||||
Cmd::Unknow(s) => {
|
||||
println!("\x1b[31;1munknown command: {}\x1b[0m", s);
|
||||
Ok(Protocol::err(&format!("ERR unknown command '{}'", s)))
|
||||
}
|
||||
Cmd::Unknow(s) => Ok(Protocol::err(&format!("ERR unknown command `{}`", s))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,24 +642,21 @@ async fn incr_cmd(server: &Server, key: &String) -> Result<Protocol, DBError> {
|
||||
}
|
||||
|
||||
fn config_get_cmd(name: &String, server: &Server) -> Result<Protocol, DBError> {
|
||||
let mut result = Vec::new();
|
||||
result.push(Protocol::BulkString(name.clone()));
|
||||
let value = match name.as_str() {
|
||||
"dir" => Some(server.option.dir.clone()),
|
||||
"dbfilename" => Some(format!("{}.db", server.selected_db)),
|
||||
"databases" => Some("16".to_string()), // Hardcoded as per original logic
|
||||
_ => None,
|
||||
};
|
||||
|
||||
match name.as_str() {
|
||||
"dir" => {
|
||||
result.push(Protocol::BulkString(server.option.dir.clone()));
|
||||
Ok(Protocol::Array(result))
|
||||
}
|
||||
"dbfilename" => {
|
||||
result.push(Protocol::BulkString(format!("{}.db", server.selected_db)));
|
||||
Ok(Protocol::Array(result))
|
||||
},
|
||||
"databases" => {
|
||||
// This is hardcoded, as the feature was removed
|
||||
result.push(Protocol::BulkString("16".to_string()));
|
||||
Ok(Protocol::Array(result))
|
||||
},
|
||||
_ => Ok(Protocol::Array(vec![])),
|
||||
if let Some(val) = value {
|
||||
Ok(Protocol::Array(vec![
|
||||
Protocol::BulkString(name.clone()),
|
||||
Protocol::BulkString(val),
|
||||
]))
|
||||
} else {
|
||||
// Return an empty array for unknown config options, which is standard Redis behavior
|
||||
Ok(Protocol::Array(vec![]))
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user