当前位置:网站首页>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 512M
Pictured :
- 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 expenses
Pictured :
- 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 :
边栏推荐
- Are the microorganisms in the intestines the same as those on the skin?
- 网络安全-CSRF
- What does the model number of asemi rectifier bridge kbpc1510 represent
- Leetcode19. Delete the penultimate node of the linked list [double pointer]
- LeetCode144. Preorder traversal of binary tree
- 微信论坛交流小程序系统毕业设计毕设(8)毕业设计论文模板
- 行测-图形推理-8-图群类
- Force deduction - question 561 - array splitting I - step by step parsing
- 微信论坛交流小程序系统毕业设计毕设(6)开题答辩PPT
- Brush question 5
猜你喜欢
Line test - graphic reasoning - 1 - Chinese character class
Transparent i/o model from beginning to end
面试百问:如何测试App性能?
Brush question 4
Ligne - raisonnement graphique - 4 - classe de lettres
Digital collections accelerated out of the circle, and marsnft helped diversify the culture and tourism economy!
微信论坛交流小程序系统毕业设计毕设(7)中期检查报告
微信论坛交流小程序系统毕业设计毕设(6)开题答辩PPT
Transform XL translation
双非大厂测试员亲述:对测试员来说,学历重要吗?
随机推荐
微信论坛交流小程序系统毕业设计毕设(4)开题报告
ArcGIS:矢量要素相同字段属性融合的两种方法
Software evaluation center ▏ what are the basic processes and precautions for automated testing?
GEE(三):计算两个波段间的相关系数与相应的p值
行測-圖形推理-4-字母類
U盘拷贝东西时,报错卷错误,请运行chkdsk
Use JfreeChart to generate curves, histograms, pie charts, and distribution charts and display them to JSP-1
GBU1510-ASEMI电源专用15A整流桥GBU1510
JS triangle
微信论坛交流小程序系统毕业设计毕设(5)任务书
iNFTnews | NFT技术的广泛应用及其存在的问题
Early childhood education industry of "screwing bar": trillion market, difficult to be a giant
Installing vmtools is gray
Leetcode interview question 02.07 Linked list intersection [double pointer]
Basic knowledge of binary tree
Debezium series: set role statement supporting mysql8
Some parameters of Haikang IPC
Innovation today | five key elements for enterprises to promote innovation
微信论坛交流小程序系统毕业设计毕设(8)毕业设计论文模板
Debezium系列之:支持 mysql8 的 set role 語句