O'Reilly logo

Redis 4.x Cookbook by Zuofei Wang, Pengcheng Huang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

To show how to choose the correct data types, we would like to save the user information of Relp in Redis. As a prototype design verification, we are going to populate some sample data for 10,000 users from Redis to check if we are using the best strategy to store user information in Redis. This means that while satisfying the business needs of the application, we will try to use as little memory as possible. For illustration purposes, the following information will be stored for one user:

  • id: user ID
  • name: user name
  • sex: m/f
  • register_time: sign-up timestamp
  • nation: the nationality of the user
  1. We check the memory consumption of an empty Redis instance:
127.0.0.1:6379> INFO MEMORY # Memory used_memory:827512 used_memory_human:808.12K ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required