Book Image

Building Scalable Apps with Redis and Node.js

By : Joshua Johanan
Book Image

Building Scalable Apps with Redis and Node.js

By: Joshua Johanan

Overview of this book

Table of Contents (17 chapters)
Building Scalable Apps with Redis and Node.js
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Redis schema


We have used Redis and a few of the data types, so let's now talk about building a Redis schema. I keep making references about how Redis is not a database system, but I feel it is a good shared perspective to discuss building a schema. Databases keep data in rows with multiple columns for each row. In addition to this, you can normalize the data and keep a reference to another row that relates keeping data separate. The end result is the same though; whether or not the database is normalized, the data is a row with multiple columns that store values. We have seen from our example application that you cannot store data this way with Redis. We will now cover some ways to build a Redis schema. The example schema we will build is for the purpose of storing users.

We want to store a user's id, username, password, and last login time. We also have the added constraint of looking up each user by their ID or username. Let's now map out the columns we will need for each user to Redis...