当前位置:网站首页>Introduction to redis and jedis and redis things
Introduction to redis and jedis and redis things
2022-07-07 23:08:00 【Scale biubiu】
Redis brief introduction :
A relational database is a database based on a relational table , Eventually, data will be persisted to disk , and nosql The database is based on a special structure , And store the data in the memory database . In terms of performance ,nosql Database is better than relational database , In terms of security, relational database is better than nosql database , So in the actual development of a project nosql Will be used with relational databases , Achieve double guarantee of performance and safety .
Redis Precautions for :
redis It's a kind of advanced key-value Storage system
Among them key It's a string type , Try to meet the following points :
- key Don't be too long. , Better not to exceed 1024 Bytes , This not only consumes memory, but also reduces lookup efficiency
- key Don't be too short. , If it's too short, it will decrease key Readability
- In the project ,key It's better to have a uniform naming convention ( According to the needs of the enterprise )
among value Five data types are supported :
- String type string
The string type is Redis The most basic data storage type in , It's in Redis Is binary safe , This means that the type can accept data in any format , Such as JPEG Image data or Json Object description information, etc . stay Redis Of string type Value The maximum length of data that can be held is 512MPictured :

- String list lists
stay Redis in ,List The type is a list of strings in insertion order . It is the same as the common linked list in data structure , We can have it on the head (left) And the tail (right) Add new elements . When inserting , If the key doesn't exist ,Redis A new linked list will be created for the key . On the contrary , If all elements in the list are removed , Then the key will also be removed from the database .List The maximum number of elements that can be contained in is 4294967295. From the efficiency perspective of element insertion and deletion , If we insert or delete elements at both ends of the list , This will It will be a very efficient operation , Even if millions of records have been stored in the linked list , This can also be done in constant time . However, it should be noted that , If the element insert or delete operation is applied to the middle of the list , That would be very inefficient . I believe that for developers with good data structure foundation , It's not hard to understand .Pictured :

- String collection sets
stay Redis in , We can Set Type as a character set without sorting , and List Same type , We can also add data values of this type 、 Delete or determine whether an element exists, etc . It should be noted that , The time of these operations is constant .Set The maximum number of elements that can be included is 4294967295. and List The difference in type is ,Set Duplicate elements are not allowed in the collection . and List Type comparison ,Set class Type also has a very important feature in function , That is, to complete multiple on the server side Sets Aggregate computing operations between , Such as unions、intersections and differences. Because these operations are completed on the server side , So it's very efficient , And it also saves a lot of network IO expensesPictured :

- Ordered string collection sorted sets
Sorted-Sets and Sets The type is very similar , They are all sets of strings , Duplicate members are not allowed to come out Now one. Set in . The main difference between them is Sorted-Sets Each member in will have a score (score) Associated with it ,Redis It's the scores that sort the members of a collection from small to large . However, it should be noted that , Even though Sorted-Sets The members of must be the only , But the score (score) But it can be repeated . stay Sorted-Set Add 、 Deleting or updating a member is a very fast operation , Its time complexity is the logarithm of the number of members in the set . because Sorted-Sets The positions of the members in the collection are ordered , therefore , Even accessing members in the middle of a collection is still very efficient . in fact ,Redis This feature is difficult to implement in many other types of databases , let me put it another way , At this point to achieve and Redis Equally efficient , Modeling in other databases is very difficult .for example : Game ranking 、 Microblog hot topics and other use scenarios .
Pictured :

- Hash type hashs
Redis Medium Hashes Type can be seen as having String Key and String Value Of map Containers . So this type is very suitable for storing information of value objects . Such as Username、Password and Age etc. . If Hash It contains very few fields , Then this type of data will only occupy a small amount of disk space . every last Hash Can be stored 4294967295 Key value pairs .Pictured :

Jedis brief introduction AND Use :
that jedis It's the integration of redis Some command operations of , Encapsulates the redis Of java client . Provides connection pool management . Generally, it is not used directly jedis, But on top of it, there is a layer of encapsulation , Use as a business . If you use spring Words , You can see spring Packaged redis Spring Data Redis
Easy to use :

Jedis Connection pool Code demonstration :

Redis thing :
边栏推荐
- Byte hexadecimal binary understanding
- Early childhood education industry of "screwing bar": trillion market, difficult to be a giant
- [record of question brushing] 3 Longest substring without duplicate characters
- 网络安全-联合查询注入
- ADC采样率(HZ)是什么怎么计算
- Talk about DART's null safety feature
- 网络安全-对操作系统进行信息查询
- Develop those things: go plus c.free to free memory, and what are the reasons for compilation errors?
- Basic knowledge of linked list
- The wonderful relationship between message queue and express cabinet
猜你喜欢

Sword finger offer 27 Image of binary tree

行测-图形推理-8-图群类

V20变频器手自动切换(就地远程切换)的具体方法示例

Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020

小程序多种开发方式对比-跨端?低代码?原生?还是云开发?

Line test - graphic reasoning -5- one stroke class

Line test - graphic reasoning - 1 - Chinese character class

The wonderful relationship between message queue and express cabinet

微信论坛交流小程序系统毕业设计毕设(8)毕业设计论文模板

微信论坛交流小程序系统毕业设计毕设(2)小程序功能
随机推荐
关于海康ipc的几个参数
U盘拷贝东西时,报错卷错误,请运行chkdsk
Interview questions: how to test app performance?
软件测评中心▏自动化测试有哪些基本流程和注意事项?
线上面试,该如何更好的表现自己?这样做,提高50%通过率~
知识点滴 - PCB制造工艺流程
Advantages and disadvantages of rest ful API
Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
网络安全-钓鱼
Basic knowledge of binary tree
面试百问:如何测试App性能?
2021-01-12
网络安全-sqlmap与DVWA爆破
Debezium series: binlogreader for source code reading
Txt file virus
行測-圖形推理-4-字母類
Mitsubishi PLC SLmP (MC) protocol
2022 words for yourself
微生物健康网,如何恢复微生物群落
PCL . VTK files and Mutual conversion of PCD




