Practice: Hash Operations · Redis

Ch 1 · Redis Hashes — card 3 of 4.

Now it is your turn to model a product as a hash. You will create one key holding several fields, read a single field and then the whole hash, and change a stock number without rewriting the other fields. A correct answer shows you can treat a hash like a small object and update one part of it in a single, safe command.

  1. Create a product hash with multiple fields
  2. Read individual and all fields
  3. Increment a numeric field
// Create product hash
// Read name field
// Read all fields
// Increment stock count