当前位置:网站首页>[redis] key hierarchy
[redis] key hierarchy
2022-06-29 01:58:00 【Riding a snail chasing a missile '】
List of articles
Key Hierarchical structure
reflection
Redis There's nothing like MySQL Medium table Concept , How can we distinguish between different types of key Well ?
- for example : Need to store users 、 Product information to redis in , There's a user id yes 1, There is a commodity id It happens to be 1.
Redis Of key Multiple words are allowed to form a hierarchy , Use... Between multiple words : separate , The format is as follows : Project name : Business name : type :id, This format is not fixed , You can delete or add entries according to your own needs .
userdependent key ->zyx:user:1productdependent key ->zyx:product:1
If value It's a java object , For example, one User object , You can serialize the object to JSON Store after string :

Using the above ideas, we are Redis Store two... In User Object data and two Product Object data :
127.0.0.1:6379[2]> SET zyx:user:1 '{"id":1, "name":"Jack", "age": 21}'
OK
127.0.0.1:6379[2]> SET zyx:user:2 '{"id":1, "name":"Rose", "age": 18}'
OK
127.0.0.1:6379[2]> SET zyx:product:1 '{"id":1, "name":" millet 11", "price": 4999}'
OK
127.0.0.1:6379[2]> SET zyx:product:2 '{"id":2, "name":" glory 6", "price": 2999}'
OK
127.0.0.1:6379[2]> KEYS *
1) "zyx:product:2"
2) "zyx:user:2"
3) "zyx:user:1"
4) "zyx:product:1"
When we open it through the graphical interface, we can clearly find our stored User、Product Object data is classified into files , Implements a hierarchical structure :

边栏推荐
- I have summarized some experiences from the whole process of R & D platform splitting
- 直播预告|SQL也能玩转工业级机器学习?MLOps meetup V3带你一探究竟!
- 利用kubernetes資源鎖完成自己的HA應用
- A full screen gesture adaptation scheme
- 大三下期末考试
- 为什么建议大家尽可能选择自研公司
- Using autogluon to forecast house price
- C language course design - food warehouse management system
- 栈的增删查改---动态内存
- [learn FPGA programming from scratch -49]: Vision - how is the chip designed?
猜你喜欢

Finally got the byte offer. The 25-year-old inexperienced experience in software testing is written to you who are still confused
Fundamentals of scala (3): operators and process control

Redis data migration (III)

Exclusive analysis | real situation of software test about resume and interview
Scala 基础 (三):运算符和流程控制

Testing until you're 35? The 35 + test will lead to unemployment?

I have summarized some experiences from the whole process of R & D platform splitting

Typescript (6) function

Analysis of parsing principle of OData metadata request response in SAP ui5 application

C language course design - food warehouse management system
随机推荐
0和1的歧义问题
How to become a senior digital IC Design Engineer (4-2) script: file read / write operation realized by Verilog HDL code
[image detection] recognition of the front and back of a coin based on texture features with matlab code attached
What is stock online account opening? Is it safe to open an account online?
In MySQL database, the two data written when creating tables with foreign keys are the same. Do I copy them or fail to display them
Advanced installer architect authoring tool
Testing until you're 35? The 35 + test will lead to unemployment?
Is the ETF fund reliable and safe
Written examination questions, answers and analysis of Digital IC design and FPGA design (2) 2021 Huawei Hisilicon (Part 1)
How does flush open an account? Is it safe to open an account online?
Fundamentals of scala (3): operators and process control
Blog publishing test 1
如何成为一名高级数字 IC 设计工程师(4-5)脚本篇:Shell 脚本实现的文件比较操作
Noip2006-2018 improvement group preliminary test questions improvement procedure questions csp-s 2019 2020 preliminary test questions improvement procedure questions
Analysis of advantages and disadvantages of environment encryption and transparent encryption
Digital IC design, FPGA design written examination questions, answers and analysis of autumn move (1) 2022 Ziguang zhanrui (Part 1)
如何成为一名高级数字 IC 设计工程师(4-2)脚本篇:Verilog HDL 代码实现的文件读写操作
[从零开始学习FPGA编程-49]:视野篇 - 芯片是如何被设计出来的?
7-27 bubble sorting (the k-th time)
如何成为一名高级数字 IC 设计工程师(6-6)数字 IC 验证篇:系统级仿真