当前位置:网站首页>Section 7 Data Dictionary: hash followed by Daewoo redis ------- directory post
Section 7 Data Dictionary: hash followed by Daewoo redis ------- directory post
2022-07-24 17:46:00 【51CTO】
One 、 Heart method
Redis hash It's a string Type of field and value Mapping table , Of course, here it is string Type refers to the string after data serialization .
Common business scenarios are to cache key value pairs . Let me give you an example , There are thirty students in one class , Every student has a unique student number , Then you can use Redis Of hash For storage . Class as a sign of these students a common (key), In other words, you can find this group of students through this class . In this group of students , Every student (value) There is also a unique logo , For example, student ID (field) To distinguish them .
data structure : key class ------ field Student number ----- value Specific students
therefore , Immediately think of using Hash Cached mental method : There is an identifier that can filter out a set of data key. In this group of filtered data , Each data itself has a unique identifier field, To identify it value. Data with such characteristics , have access to Redis Of hash As caching .
Common business scenarios
( One ) Cache dictionary table . A simple dictionary table , Refer to the following figure .type Field as key, code Field as field, The corresponding records serve as value.
( Two ) Cache normal tables . Table name (key) Used to filter a set of data ( All the data in this table ), The primary key of the record ID(field) As each data (value) Unique identifier of .
Two 、 Use Hash Example
Pages often have key value pairs similar to drop-down boxes . such as , Color 、 Gender . These data will be stored in the dictionary table of the system .
I consider when the system goes online , Load all the data of the dictionary table into Redis The cache . And every time you operate the dictionary , Update cache .

For example, there is the dictionary table above . Suppose there is a management page , Add a record , If the operation of the dictionary table is successful , Then query all the data in this dictionary table , Add it to Redis The cache . for example color As type, Can identify the color category .sex As type, Can express the gender category .
The data structure is as follows :
Key ----------------- field --------------------- value
Custom constant type Field Multiple records of corresponding types List<Parameter>
How to get it ?
I'll add a dictionary table data first , Trigger the above load cache operation , According to type, Load in Redis In cache .

Then request all dictionary table data on the page , Of course, all these data come from Redis in , Can avoid and DB Interact .

Final test , according to type To get the specified dictionary table data .

边栏推荐
- 微信朋友圈的高性能复杂度分析
- 700. Search DFS method in binary search tree
- Trends of semiconductor industry
- Getaverse, a distant bridge to Web3
- Mobile robot (IV) four axis aircraft
- Ipaylinks, a cross-border payment integration service, won the 3A Asia Award of treasury
- 0615~用自定义注解实现RBAC权限管理
- C language custom type explanation - structure
- 简单测试JS代码
- 阿里巴巴1688按关键字搜索商品 API 使用展示
猜你喜欢

Can Lu Zhengyao hide from the live broadcast room dominated by Luo min?

OpenCV 图片旋转

使用matplotlib模拟线性回归

Atcoder beginer 202 e - count descendants (heuristic merge on heavy chain split tree for offline query)

SV强制类型转换和常数

Use prometheus+grafana to monitor MySQL performance indicators

2022 Asia International Internet of things exhibition

Iqiyi Tiktok reconciled, Weibo lying gun?

C语言编程训练题目:左旋字符串中的k个字符、小乐乐与欧几里得、打印箭型图案、公务员面试、杨树矩阵

分家后印象笔记过日子依然不好过,骚操作却不少
随机推荐
The results of the second quarter online moving people selection of "China Internet · moving 2022" were announced
High performance complexity analysis of wechat circle of friends
HCNP Routing&Switching之DHCP中继
Ipaylinks, a cross-border payment integration service, won the 3A Asia Award of treasury
Get the data of Tongcheng (elong) Hotel
Tensorflow introductory tutorial (40) -- acunet
Df2net 3D model deployment
Getaverse, a distant bridge to Web3
ansible自动化运维详解(五)ansible中变量的设定使用、JINJA2模板的使用以及ansible的加密控制
Use Matplotlib to simulate linear regression
Is it safe for qiniu to open an account?
awk从入门到入土(19)awk扩展插件,让awk如虎添翼
pinia 入门及使用
Eth POS 2.0 stacking test network pledge process
Quickly complete the unit test junit4 setting of intelij idea
Tensorflow introductory tutorial (37) -- DC Vnet
0625~<config>-<bus>
【网络安全】网站中间件存在的解析漏洞
Can Lu Zhengyao hide from the live broadcast room dominated by Luo min?
Array double pointer - deliberate practice