Redis的key按object-type:id:field格式设计的原因??
网上很多人都这么做,还有人明说这可以提升查询效率
但好像没人解释为什么这么做
难道仅仅为了易阅读??
PHP中文网2017-04-21 11:19:50
This is indeed a design issue.
Let’s not talk about redis first, let’s talk about relational databases first, which are generally based on table design, so they can support various queries, right?
So what should I do with NoSQL in general? Like mongodb's documented storage method, collections are similar to tables in relational databases and can also complete most of the query and indexing work.
What about redis? It is based on key-value. For example, what should you do if you want to query by id or name? The answer is to create an index yourself.
The most basic way is the object-type:id:field you mentioned above. Check student number 01: person:01.