Skip to main content

Giordani L. Rust Projects. Write A Redis Clone.... Here

pub fn flushall(&self) self.inner.lock().unwrap().clear();

pub fn exists(&self, key: &str) -> bool self.get(key).is_some() Giordani L. Rust Projects. Write a Redis Clone....

let key = match &args[0] RespValue::BulkString(Some(k)) => String::from_utf8_lossy(k).to_string(), _ => return RespValue::Error("ERR invalid key".to_string()), ; pub fn flushall(&self) self

pub async fn run(&self) -> Result<(), Box<dyn std::error::Error>> { loop { let (socket, addr) = self.listener.accept().await?; let store = self.store.clone(); tokio::spawn(async move { if let Err(e) = handle_client(socket, store).await { eprintln!("Error handling client {}: :?", addr, e); } }); } } } pub fn flushall(&self) self.inner.lock().unwrap().clear()