Adding commands and interaction functions

The tool that we are creating for Redis will support three commands:

  • add - adds a new session record
  • remove - removes a session record by key (that is, by username)
  • list - prints all session records

We need constants for the name of every subcommand to prevent mistakes in strings in the code:

const SESSIONS: &str = "sessions";
const CMD_ADD: &str = "add";
const CMD_REMOVE: &str = "remove";
const CMD_LIST: &str = "list";

This list also contains the SESSION constant as the name of the HashMap in Redis. Now, we can declare functions to manipulate session data.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.101.81