server: implement key expiration (#13)

This commit is contained in:
Carl Lerche
2020-03-25 13:45:54 -07:00
committed by GitHub
parent 49b848b805
commit fc5597f293
12 changed files with 348 additions and 220 deletions

View File

@@ -1,5 +1,5 @@
use crate::cmd::{Parse, ParseError};
use crate::{Connection, Frame, Kv};
use crate::{Connection, Frame, Db};
use bytes::Bytes;
use std::io;
@@ -42,9 +42,9 @@ impl Set {
}
#[instrument]
pub(crate) async fn apply(self, kv: &Kv, dst: &mut Connection) -> io::Result<()> {
pub(crate) async fn apply(self, db: &Db, dst: &mut Connection) -> io::Result<()> {
// Set the value
kv.set(self.key, self.value, self.expire);
db.set(self.key, self.value, self.expire);
let response = Frame::Simple("OK".to_string());
debug!(?response);