Skip to content

Commit

Permalink
Merge pull request #23 from shashitnak/feature/echo
Browse files Browse the repository at this point in the history
adding support for echo command
  • Loading branch information
seppo0010 authored Jun 6, 2023
2 parents 03c2827 + 187aceb commit e500296
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions command/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ fn dump(parser: &mut ParsedCommand, db: &mut Database, dbindex: usize) -> Respon
}
}

fn echo(parser: &mut ParsedCommand) -> Response {
validate_arguments_exact!(parser, 2);
let msg = try_validate!(parser.get_str(1), "Syntax error");
Response::Data(msg.as_bytes().to_vec())
}

fn generic_expire(db: &mut Database, dbindex: usize, key: Vec<u8>, msexpiration: i64) -> Response {
Response::Integer(match db.get(dbindex, &key) {
Some(_) => {
Expand Down Expand Up @@ -2777,6 +2783,7 @@ fn execute_command(
"pexpire" => pexpire(parser, db, dbindex),
"expireat" => expireat(parser, db, dbindex),
"expire" => expire(parser, db, dbindex),
"echo" => echo(parser),
"ttl" => ttl(parser, db, dbindex),
"pttl" => pttl(parser, db, dbindex),
"persist" => persist(parser, db, dbindex),
Expand Down

0 comments on commit e500296

Please sign in to comment.