Hegwin.Me

The hydra-universe twisting its body scaled in stars.

Start to roll with Redis

Redis入门心得

The concept of NoSQL has been around for a long time, but I've only recently started using Redis.

I was introduced to Redis at the end of 2012, when I was using version 2.6.7, and my scenario was to store address information (province, city, district, street) into Redis as a cache for quick reads when I initialized the project. I didn't use it for anything else, so I didn't delve into Redis at that time.

I started using Redis more in a recent project, and the version was already 3.0. We read data from third parties, but the speed was quite slow, so we used Redis for a fast cache, and we also used Redis to store some local settings.

Books to get started

I recommend Redis Getting Started Guide. This book is a great way to get started with Redis.

I am recommended to read the book to learn (rather than blogs), and the book is very thin and can be quickly turned through. And the author needs to organize a complete system in order to be able to become a book, which is also considered to have everything. An article on the Internet, often only to a point, does not cover all.

To be honest, I have not read any other books. So it is not good to compare it with other books. I saw this book in a bookstore with another programmer friend, and we thought it was pretty good, but I didn't use Redis at that time, so I didn't buy it. However, I scanned the barcode and added it to my collection.

Basic Concept

I think most of us have the concept of K-V store, so I don't need to mention it much.

Redis has five data types, and they are not nestable (by saying "not nestable", I mean, for example, a set cannot be a value of a hash table):

  • Strings
  • Hash
  • Lists
  • Sets
  • Sorted Sets

The reason for understanding data types is that different Redis commands are for different kinds of data. Here you can see Redis's Command API, and you need to know what data type you're operating on before you can know what command you're going to pick.

Generally speaking, commands with different data structures can be distinguished directly from the commands themselves, for example, command names for hashes are in the format of "H+Action", such as HSET, HGETALL, and so on; similarly, list commands start with L(List) such as LRANGE. Commands for Sets are S, and Z for Sorted Sets.

< Back