July 2017
Intermediate to advanced
656 pages
16h 1m
English
If both author and quote are specified via the command line, we go ahead and generate a random key prefixed with Quote:. So, each key will look something like Quote:0e3h6euk01vo. It's a common convention to prefix the Redis keys with names delimited by a colon as this helps us to identify keys when debugging.
We pass our key into client.hmset, a wrapper for the Redis HMSET command, which allows us to create multiple hashes.
Essentially, when called with params.author set to Steve Jobs and params.quote set to Stay hungry, stay foolish, the following command is sent to Redis and executed (where HASH is the string we generate with Math.random().toString(32).replace('.', '')):
HMSET Quotes:HASH author "Steve Jobs" quote "Stay ...