[Redis]Redis 概述及基本使用规范.

<p class="17" style="margin-left: 18pt; line-height: normal; text-indent: -18pt; mso-char-indent-count: 0.0000; mso-list: l23 level1 lfo2;"><span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 22.0000pt;"><span style="mso-list: ignore;"><span style="font-family: Calibri;"><span style="font-size: 22pt;">1 n<span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 22.0000pt; mso-spacerun: 'yes';"><span style="font-size: 22pt;"><span style="font-family: Calibri;">osql<span style="face: 宋体;"><span style="font-size: 22pt;">的简介


<h2 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 28.8pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -28.8pt; mso-list: l22 level2 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: 'Calibri Light'; mso-hansi-font-family: 'Calibri Light';"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.1 <span style="font-size: 16pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: 'Calibri Light'; mso-hansi-font-family: 'Calibri Light';">nosql<span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="font-size: 16pt;">简介
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;">随着互联网<span style="font-size: 10.5pt;">Web2.0网站的兴起,传统的关系数据库在应付<span style="font-size: 10.5pt;"><span style="face: calibri;">Web2.0<span style="face: 宋体;">网站,特别是超大规模和高并发的<span style="face: calibri;">SNS<span style="face: 宋体;">类型的<span style="face: calibri;">Web2.0<span style="face: 宋体;"><span style="font-size: 10.5pt;">纯动态网站已经显得力不从心,暴露了很多难以克服的问题,如:


<h3 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 36pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -36pt; mso-list: l22 level3 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.1.1 <span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-size: 16pt;">对数据库高并发读写的需求
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> 网站要根据用户个性化信息来实时生成动态页面和提供动态信息,所以基本上无法使用动态页面静态化技术,因此数据库并发负载非常高,往往要达到每秒上万次读写请求。关系数据库应付上万次<span style="font-size: 10.5pt;">SQL查询还勉强顶得住,但是应付上千万次<span style="font-size: 10.5pt;"><span style="face: calibri;">SQL<span style="face: 宋体;">写数据请求,硬盘<span style="face: calibri;">IO<span style="face: 宋体;"><span style="font-size: 10.5pt;">就已经无法承受了。


<h3 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 36pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -36pt; mso-list: l22 level3 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.1.2 <span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-size: 16pt;">对海量数据的高效率存储和访问的需求
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> 对于大型的<span style="font-size: 10.5pt;">SNS网站,每天用户产生海量的用户动态,以国外的<span style="font-size: 10.5pt;"><span style="face: calibri;">Friendfeed<span style="face: 宋体;">为例,一个月就达到了<span style="face: calibri;">2.5<span style="face: 宋体;">亿条用户动态,对于关系数据库来说,在一张<span style="face: calibri;">2.5<span style="face: 宋体;">亿条记录的表里面进行<span style="face: calibri;">SQL<span style="face: 宋体;"><span style="font-size: 10.5pt;">查询,效率是极其低下乃至不可忍受的。


<h3 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 36pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -36pt; mso-list: l22 level3 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.1.3 <span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-size: 16pt;">对数据库的高可扩展性和高可用性的需求
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> 在基于<span style="font-size: 10.5pt;">Web的架构当中,数据库是最难进行横向扩展的,当一个应用系统的用户量和访问量与日俱增的时候,你的数据库却没有办法像<span style="font-size: 10.5pt;"><span style="face: calibri;">Web<span style="face: 宋体;">服务器和应用服务器那样简单的通过添加更多的硬件和服务节点来扩展性能和负载能力。对于很多需要提供<span style="face: calibri;">7*24<span style="face: 宋体;"><span style="font-size: 10.5pt;">小时不间断服务的网站来说,对数据库系统进行升级和扩展是非常痛苦的事情,往往需要停机维护和数据迁移,为什么数据库不能通过不断的添加服务器节点来实现扩展呢?


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> 在上面提到的<span style="font-size: 10.5pt;">“三高”的需求面前,关系数据库遇到了难以克服的障碍,而对于<span style="font-size: 10.5pt;"><span style="face: calibri;">Web2.0<span style="face: 宋体;"><span style="font-size: 10.5pt;">网站来说,关系数据库的很多主要特性却往往无用武之地,例如:


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> (<span style="font-size: 10.5pt;">1<span style="font-size: 10.5pt;">)数据库事务一致性需求


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> 很多<span style="font-size: 10.5pt;">Web<span style="font-size: 10.5pt;">实时系统并不要求严格的数据库事务,对读一致性的要求很低,有些场合对写一致性要求也不高。因此数据库事务管理成了数据库高负载下一个沉重的负担。


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> (<span style="font-size: 10.5pt;">2<span style="font-size: 10.5pt;">)数据库的写实时性和读实时性需求


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="face: 宋体;"><span style="font-size: 10.5pt;"> 对关系数据库来说,插入一条数据之后立刻查询,是肯定可以读出来这条数据的。并不要求这么高的实时性。


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> (<span style="font-size: 10.5pt;">3)对复杂的<span style="font-size: 10.5pt;"><span style="face: calibri;">SQL<span style="face: 宋体;"><span style="font-size: 10.5pt;">查询,特别是多表关联查询的需求


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> 任何大数据量的<span style="font-size: 10.5pt;">Web系统,都非常忌讳多个大表的关联查询,以及复杂的数据分析类型的复杂<span style="font-size: 10.5pt;"><span style="face: calibri;">SQL<span style="face: 宋体;">报表查询,特别是<span style="face: calibri;">SNS<span style="face: 宋体;">类型的网站,从需求以及产品设计角度,就避免了这种情况的产生。往往更多的只是单表的主键查询,以及单表的简单条件分页查询,<span style="face: calibri;">SQL<span style="face: 宋体;"><span style="font-size: 10.5pt;">的功能被极大的弱化了。


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="font-family: Calibri;"><span style="font-size: 10.5pt;"> <a href="http://images2015.cnblogs.com/blog/799093/201608/799093-20160825230830726-1942580122.png"&gt;

<img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="wpsBF6D.tmp" src="https://www.jb51.cc/res/2019/02-14/22/83c85e1ce8d09b931c7b923afabda928.png" alt="wpsBF6D.tmp" width="606" height="430" border="0">


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> 因此,关系数据库在这些越来越多的应用场景下显得不那么合适了,为了解决这类问题的非关系数据库应运而生。<span style="font-size: 10.5pt;">NoSQL 是非关系型数据存储的广义定义。它打破了长久以来关系型数据库与<span style="font-size: 10.5pt;"><span style="face: calibri;">ACID<span style="face: 宋体;">理论大一统的局面。<span style="face: calibri;">NoSQL <span style="face: 宋体;"><span style="font-size: 10.5pt;">数据存储不需要固定的表结构(例如以键值对存储,它的结构不固定,每一个元组可以有不一样的字段,每个元组可以根据需要增加一些自己的键值对,这样就不会局限于固定的结构,可以减少一些时间和空间的开销),通常也不存在连接操作。


<h2 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 28.8pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -28.8pt; mso-list: l22 level2 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: 'Calibri Light'; mso-hansi-font-family: 'Calibri Light';"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.2 <span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: 'Calibri Light'; mso-hansi-font-family: 'Calibri Light';"><span style="font-size: 16pt;">NoSQL<span style="font-size: 16pt;">无与伦比的特点
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="face: 宋体;"><span style="font-size: 10.5pt;"> 在大数据存取上具备关系型数据库无法比拟的性能优势,例如:


<h3 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 36pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -36pt; mso-list: l22 level3 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.2.1 <span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-size: 16pt;">易扩展
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;">NoSQL<span style="font-size: 10.5pt;">数据库种类繁多,但是一个共同的特点都是去掉关系数据库的关系型特性。数据之间无关系,这样就非常容易扩展。也无形之间,在架构的层面上带来了可扩展的能力。


<h3 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 36pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -36pt; mso-list: l22 level3 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.2.2 <span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-size: 16pt;">大数据量,高性能
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;">NoSQL<span style="font-size: 10.5pt;">数据库都具有非常高的读写性能,尤其在大数据量下,同样表现优秀。这得益于它的无关系性,数据库的结构简单。


<h3 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 36pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -36pt; mso-list: l22 level3 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.2.3 <span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-size: 16pt;">灵活的数据模型
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;">NoSQL无需事先为要存储的数据建立字段,随时可以存储自定义的数据格式。而在关系数据库里,增删字段是一件非常麻烦的事情。如果是非常大数据量的表,增加字段简直就是一个噩梦。这点在大数据量的<span style="font-size: 10.5pt;"><span style="face: calibri;">Web2.0<span style="face: 宋体;"><span style="font-size: 10.5pt;">时代尤其明显。


<h3 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 36pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -36pt; mso-list: l22 level3 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.2.4 <span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-size: 16pt;">高可用
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 21pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;">NoSQL在不太影响性能的情况,就可以方便的实现高可用的架构。比如<span style="font-size: 10.5pt;"><span style="face: calibri;">Cassandra<span style="face: 宋体;">,<span style="face: calibri;">HBase<span style="face: 宋体;"><span style="font-size: 10.5pt;">模型,通过复制模型也能实现高可用。


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 21pt;" align="justify"><span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="font-family: Calibri;"><span style="font-size: 10.5pt;"> 


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;">综上所述,<span style="font-size: 10.5pt;">NoSQL的非关系特性使其成为了后<span style="font-size: 10.5pt;"><span style="face: calibri;">Web2.0<span style="face: 宋体;">时代的宠儿,助力大型<span style="face: calibri;">Web2.0<span style="face: 宋体;"><span style="font-size: 10.5pt;">网站的再次起飞,是一项全新的数据库革命性运动。


<h2 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 28.8pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -28.8pt; mso-list: l22 level2 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: 'Calibri Light'; mso-hansi-font-family: 'Calibri Light';"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.3 <span style="font-size: 16pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: 'Calibri Light'; mso-hansi-font-family: 'Calibri Light';">redis<span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="font-size: 16pt;">简介
<p class="p" style="margin-bottom: 0pt; background: #ffffff; margin-top: 0pt; line-height: 15pt; text-indent: 21pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;">随着应用对高性能需求的增加,<span style="font-size: 10.5pt;">NoSQL逐渐在各大名企的系统架构中生根发芽。时至今日,涌现出的<span style="font-size: 10.5pt;"><span style="face: calibri;">NoSQL<span style="face: 宋体;">产品已经有很多种了,例如<span style="font-size: 10.5pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="color: #ff0000;"><span style="font-family: 宋体;">Membase、<span style="face: calibri;">MongoDB<span style="face: 宋体;">、<span style="face: calibri;">Apache Cassandra<span style="face: 宋体;">、<span style="face: calibri;">CouchDB<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="face: 宋体;">等。不过,在国内外互联网巨头例如<span style="color: #ff0000;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;">社交巨头新浪微博、传媒巨头Viacom及图片分享领域佼佼者<span style="face: calibri;">Pinterest<span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;">等名企都不约而同地采用了<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;">Redis<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-size: 10.5pt;"><span style="font-family: 宋体;">作为其NoSQL数据库的选择,到底<span style="face: calibri;">Redis<span style="face: 宋体;"><span style="font-size: 10.5pt;">是何方神圣呢?能让如此多的名企为它而痴狂。


<p class="p" style="margin-bottom: 0pt; background: #ffffff; margin-top: 0pt; line-height: 15pt; text-indent: 0pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> 按照官方的说法,<span style="font-size: 10.5pt;">Redis是一个开源的,使用<span style="font-size: 10.5pt;"><span style="face: calibri;">C<span style="face: 宋体;">语言编写,面向“键<span style="face: calibri;">/<span style="face: 宋体;">值”(<span style="face: calibri;">Key/Value<span style="face: 宋体;">)对类型数据的分布式<span style="face: calibri;">NoSQL<span style="face: 宋体;">数据库系统,特点是<span style="font-size: 10.5pt;"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;">高性能<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;">,<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;">持久存储<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;">,<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;">适应高并发的应用场景<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;">。因此,可以说Redis纯粹为应用而产生,它是一个高性能的<span style="face: calibri;">key-value<span style="face: 宋体;">数据库,并且还提供了多种语言的<span style="face: calibri;">API<span style="face: 宋体;">(包括我们的大<span style="face: calibri;">C#<span style="face: 宋体;">)。那么,也许我们会问:<span style="font-family: 宋体;"><span style="font-size: 10.5pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="color: #ff0000;">到底性能如何呢?以下是官方的bench-mark数据<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-size: 10.5pt;">:


<p class="MsoNormal" style="background: #ffffa3; text-justify: inter-ideograph; margin: 0pt; line-height: 19.2pt; text-indent: 0pt;" align="justify"><span style="color: #333333;"><span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="face: 宋体;"><span style="font-size: 10.5pt;"> 测试完成了<span style="font-size: 10.5pt;"><span class="16" style="mso-spacerun: 'yes';">50<span style="face: 宋体;">个并发<span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="face: 宋体;">执行<span class="16" style="mso-spacerun: 'yes';">100000<span style="face: 宋体;">个请求<span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="face: 宋体;"><span style="font-size: 10.5pt;">。


<p class="MsoNormal" style="background: #ffffa3; text-justify: inter-ideograph; margin: 0pt; line-height: 19.2pt; text-indent: 0pt;" align="justify"><span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="color: #333333;"><span style="face: 宋体;"><span style="font-size: 10.5pt;"> 设置和获取的值是一个<span style="font-size: 10.5pt;">256<span style="face: 宋体;"><span style="font-size: 10.5pt;">字节字符串。


<p class="MsoNormal" style="background: #ffffa3; text-justify: inter-ideograph; margin: 0pt; line-height: 19.2pt; text-indent: 0pt;" align="justify"><span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="color: #333333;"><span style="font-size: 10.5pt;">Linux box<span style="face: 宋体;">是运行<span style="face: 微软雅黑;">Linux 2.6,<span style="face: 宋体;">这是<span style="face: 微软雅黑;">X3320 Xeon 2.5 ghz<span style="face: 宋体;"><span style="font-size: 10.5pt;">。


<p class="MsoNormal" style="background: #ffffa3; text-justify: inter-ideograph; margin: 0pt; line-height: 19.2pt; text-indent: 0pt;" align="justify"><span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="color: #333333;"><span style="face: 宋体;"><span style="font-size: 10.5pt;"> 文本执行使用<span style="font-size: 10.5pt;">loopback<span style="face: 宋体;">接口<span style="face: 微软雅黑;">(127.0.0.1)<span style="face: 宋体;"><span style="font-size: 10.5pt;">。


<p class="MsoNormal" style="background: #ffffa3; text-justify: inter-ideograph; margin: 0pt; line-height: 19.2pt; text-indent: 0pt;" align="justify"><span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="color: #333333; font-family: 宋体;"><span style="font-size: 10.5pt;"> 结果<span style="font-size: 10.5pt;"><span style="color: #ff0000;"><span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';">:<span class="16" style="mso-spacerun: 'yes';"><span style="face: 宋体;">读的速度是110000<span style="face: 宋体;">次<span style="face: 微软雅黑;">/s,<span style="face: 宋体;">写的速度是<span style="face: 微软雅黑;">81000<span style="face: 宋体;">次<span style="face: 微软雅黑;">/s<span class="15" style="mso-spacerun: 'yes';"> <span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="face: 宋体;"><span style="font-size: 10.5pt; color: #333333;">。(当然不同的服务器配置性能也有所不同)。


<p class="p" style="margin-bottom: 0pt; background: #ffffff; margin-top: 0pt; line-height: 15pt; text-indent: 0pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;"> 和<span style="font-size: 10.5pt;">Memcached类似,<span style="font-size: 10.5pt;"><span style="face: calibri;">Redis<span style="face: 宋体;">支持存储的<span style="face: calibri;">value<span style="face: 宋体;">类型相对更多,包括<span style="face: calibri;">string(<span style="face: 宋体;">字符串<span style="face: calibri;">)<span style="face: 宋体;">、<span style="face: calibri;">list(<span style="face: 宋体;">链表<span style="face: calibri;">)<span style="face: 宋体;">、<span style="face: calibri;">set(<span style="face: 宋体;">集合<span style="face: calibri;">)<span style="face: 宋体;">、<span style="face: calibri;">zset(sorted set --<span style="face: 宋体;">有序集合<span style="face: calibri;">)<span style="face: 宋体;">和<span style="face: calibri;">hash<span style="face: 宋体;">(哈希类型)。这些数据类型都支持<span style="face: calibri;">push/pop<span style="face: 宋体;">、<span style="face: calibri;">add/remove<span style="face: 宋体;">及取交集并集和差集及更丰富的操作,而且这些操作都是原子性的。在此基础上,<span style="face: calibri;">Redis<span style="face: 宋体;">支持各种不同方式的排序。与<span style="face: calibri;">Memcached<span style="face: 宋体;">一样,为了保证效率,数据都是缓存在内存中。区别的是<span style="font-size: 10.5pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="color: #ff0000;"><span style="font-family: 宋体;">Redis会周期性的把更新的数据写入磁盘或者把修改操作写入追加的记录文件,并且在此基础上实现了<span style="face: calibri;">master-slave(<span style="face: 宋体;">主从<span style="face: calibri;">)<span style="face: 宋体;">同步<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="face: 宋体;"><span style="font-size: 10.5pt;">(数据可以从主服务器向任意数量的从服务器上同步,从服务器可以是关联其他从服务器的主服务器。)。


<p class="p" style="margin-bottom: 0pt; background: #ffffff; margin-top: 0pt; line-height: 15pt; text-indent: 18pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="face: 宋体;"><span style="font-size: 10.5pt;">因此,<span style="font-size: 10.5pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;">Redis的出现,很大程度补偿了<span style="face: calibri;">Memcached<span style="face: 宋体;">这类<span style="face: calibri;">key/value<span style="face: 宋体;">存储的不足,在部分场合可以对关系数据库起到很好的补充作用<span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="face: 宋体;"><span style="font-size: 10.5pt;">。


<h2 style="margin-bottom: 13pt; margin-top: 13pt; margin-left: 28.8pt; text-justify: inter-ideograph; line-height: 28pt; text-indent: -28.8pt; mso-list: l22 level2 lfo1;" align="justify"><span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-ascii-font-family: 'Calibri Light'; mso-hansi-font-family: 'Calibri Light';"><span style="mso-list: ignore;"><span style="font-size: 16pt;">1.4 <span style="font-size: 16pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: 'Calibri Light'; mso-hansi-font-family: 'Calibri Light';">redis<span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="font-size: 16pt;">是什么
<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 21pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;">redis是一个开源的、使用<span style="font-size: 10.5pt;"><span style="face: calibri;">C<span style="face: 宋体;">语言编写的、支持网络交互的、可基于内存也可持久化的<span style="face: calibri;">Key-Value<span style="face: 宋体;"><span style="font-size: 10.5pt;">数据库。


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 21pt;" align="justify"><span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="font-family: Calibri;"><span style="font-size: 10.5pt;"> 


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><a href="http://images2015.cnblogs.com/blog/799093/201608/799093-20160825230832788-1929964806.jpg"&gt;

<img style="background-image: none; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border: 0px;" title="wpsBF6E.tmp" src="https://www.jb51.cc/res/2019/02-14/22/a3a86c32e0a74b66e5a158497067f8af.jpg" alt="wpsBF6E.tmp" width="194" height="192" border="0">

<span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes';"><span style="font-family: Calibri;"><span style="font-size: 10.5pt;"> 


<p class="MsoNormal" style="text-justify: inter-ideograph; margin: 0pt; line-height: normal; text-indent: 0pt;" align="justify"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="font-family: 宋体;"><span style="font-size: 10.5pt;">redis的作者,<span style="font-size: 10.5pt;"><span style="face: calibri;">Salvatore Sanfilippo<span style="face: 宋体;">,来自意大利的西西里岛,现在居住在卡塔尼亚。目前供职于<span style="face: calibri;">Pivotal<span style="face: 宋体;">公司。他使用的网名是<span style="face: calibri;">antirez<span style="face: 宋体;">,如果你有兴趣,可以去他的博客逛逛,地址是<span style="face: calibri;">antirez.com<span style="face: 宋体;">,他的<span style="face: calibri;">github<span style="face: 宋体;">地址是<span style="face: calibri;">http://github.com/antirez<span style="face: 宋体;"><span style="font-size: 10.5pt;">。


<h1 style="margin-bottom: 16.5pt; margin-top: 17pt; margin-left: 21.6pt; text-justify: inter-ideograph; line-height: 53pt; text-indent: -21.6pt; mso-list: l22 level1 lfo1;" align="justify">
<span style="font-family: 宋体;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 22.0000pt; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;"><span style="mso-list: ignore;"><span style="font-size: 22pt;">2 <span style="font-size: 22pt;"><span style="mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 22.0000pt; mso-spacerun: 'yes'; mso-ascii-font-family: calibri; mso-hansi-font-family: calibri;">CentOS下<span style="mso-fareast-font-family: 宋体; mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 22.0000pt; mso-spacerun: 'yes';"><span style="font-size: 22pt;"><span style="face: 宋体;">安装<span style="font-family: Calibri;"><span style="font-size: 22pt;">redis

 

 

 

 

 

 

 

 

 

 

 

 

 

 

wpsBF6F.tmp

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

wpsBF70.tmp

 

wpsBF71.tmp

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

wpsBF82.tmp

wpsBF83.tmp

 

wpsBF84.tmp

 

wpsBF85.tmp

 

 

 

 

 

 

 

 

 

 

 

 

 

 

wpsBF86.tmp

 

wpsBF87.tmp

 

wpsBF88.tmp

 

 

wpsBF98.tmp

 

wpsBF99.tmp

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


文章浏览阅读1.3k次。在 Redis 中,键(Keys)是非常重要的概念,它们代表了存储在数据库中的数据的标识符。对键的有效管理和操作是使用 Redis 数据库的关键一环,它直接影响到数据的存取效率、系统的稳定性和开发的便利性。本文将深入探讨 Redis 中键的管理和操作,包括键的命名规范、常用的键操作命令以及一些最佳实践。我们将详细介绍如何合理命名键、如何使用键的过期和持久化特性、如何批量删除键等技巧,旨在帮助读者更好地理解并灵活运用 Redis 中的键,从而提高数据管理和操作的效率和可靠性。
文章浏览阅读3.3k次,点赞44次,收藏88次。本篇是对单节点的应用,但从中我们也能推断出一些关于集群的应用,不过大多数公司能搞个主从就已经是不错了,所以你能学会这个已经算是很有用了,关于ES,博主前面也讲过一些基础应用,创建一个工具类利用ES的数据模型进行存储就可以达到一个canal同时对Redis和ES的同步,如果担心出问题,可以把Canal搞成集群的形式,这个后续有时间博主再给大家做讲解。今天就到这里了,觉得不错就支持一下吧。_canal redis
文章浏览阅读8.4k次,点赞8次,收藏18次。Spring Boot 整合Redis实现消息队列,RedisMessageListenerContainer的使用,Pub/Sub模式的优缺点_springboot redis 消息队列
文章浏览阅读978次,点赞25次,收藏21次。在Centos上安装Redis5.0保姆级教程!_centos7 安装redis5.0服务器
文章浏览阅读1.2k次,点赞21次,收藏22次。Docker-Compose部署Redis(v7.2)主从模式首先需要有一个redis主从集群,才能接着做redis哨兵模式。_warning: sentinel was not able to save the new configuration on disk!!!: dev
文章浏览阅读2.2k次,点赞59次,收藏38次。合理的JedisPool资源池参数设置能为业务使用Redis保驾护航,本文将对JedisPool的使用、资源池的参数进行详细说明,最后给出“最合理”配置。_jedispool资源池优化
文章浏览阅读1.9k次。批量删除指定前缀的Key有两中方法,一种是借助 redis-cli,另一种是通过 SCAN命令来遍历所有匹配前缀的 key,并使用 DEL命令逐个删除它们。_redis删除前缀的key
文章浏览阅读890次,点赞18次,收藏20次。1. Redis时一个key-cakye的数据库,key一般是String类型,不过value类型有很多。eg.String Hash List Set SortedSet (基本) | GEO BitMap HyperLog (特殊)2.Redis为了方便学习,将操作不同类型的命令做了分组,在官网可以进行查询。
文章浏览阅读1.1k次,点赞19次,收藏26次。若不使用Redisson,而是用synchronized(this),此时会造成对服务器的加锁,若开始大量查询ID为1的商品,每台机器都会先跑一遍加个锁,然后在查询ID为2的数据,此时需要等待ID为1的锁释放,所以需要将this对象调整为全局商品ID。若在执行bgsave命令时,还有其他redis命令被执行(主线程数据修改),此时会对数据做个副本,然后bgsave命令执行这个副本数据写入rdb文件,此时主线程还可以继续修改数据。在当前redis目录下会生成aof文件,对redis修改数据的命令进行备份。
文章浏览阅读1.5k次,点赞39次,收藏24次。本文全面剖析Redis集群在分布式环境下的数据一致性问题,从基础原理到高级特性,涵盖主从复制、哨兵模式、持久化策略等关键点,同时也分享了关于监控、故障模拟与自适应写一致性策略的实践经验。_redis集群一致性
文章浏览阅读1k次。RDB因为是二进制文件,在保存的时候体积也是比较小的,它恢复的比较快,但是它有可能会丢数据,我们通常在项目中也会使用AOF来恢复数据,虽然AOF恢复的速度慢一些,但是它丢数据的风险要小很多,在AOF文件中可以设置刷盘策略,我们当时设置的就是每秒批量写入一次命令。AOF的含义是追加文件,当redis操作写命令的时候,都会存储这个文件中,当redis实例宕机恢复数据的时候,会从这个文件中再次执行一遍命令来恢复数据。:在Redis中提供了两种数据持久化的方式:1、RDB 2、AOF。
文章浏览阅读1k次,点赞24次,收藏21次。NoSQL(No only SQL)数据库,泛指非关系型数据库,实现对于传统数据库而言的。NoSQL 不依赖业务逻辑方式进行存储,而以简单的 key-value 模式存储。因此大大增加了数据库的扩展能力。不遵循SQL标准不支持ACID远超于SQL的性能Redis是当前比较热门的NOSQL系统之一,它是一个开源的使用ANSI c语言编写的key-value存储系统(区别于MySQL的二维表格的形式存储。
文章浏览阅读988次,点赞17次,收藏19次。在上面的步骤中,我们已经开启了 MySQL 的远程访问功能,但是,如果使用 MySQL 管理工具 navicat 连接 MySQL 服务端时,还是可能会出现连接失败的情况。在实际工作中,如果我们需要从其他地方访问和管理 MySQL 数据库,就需要开启 MySQL 的远程访问功能并设置相应的权限。这对于我们的工作效率和数据安全都有很大的帮助。通过查看 MySQL 用户表,我们可以看到’host’为’%’,说明 root 用户登录 MySQL 的时候,可以允许任意的 IP 地址访问 MySQL 服务端。
文章浏览阅读956次。Redis Desktop Manager(RDM)是一款用于管理和操作Redis数据库的图形化界面工具。提供了简单易用的界面,使用户能够方便地执行各种Redis数据库操作,并且支持多个Redis服务器的连接_redisdesktopmanager安装包
文章浏览阅读1.9k次,点赞52次,收藏27次。缓存击穿指的是数据库有数据,缓存本应该也有数据,但是缓存过期了,Redis 这层流量防护屏障被击穿了,请求直奔数据库。缓存穿透指的是数据库本就没有这个数据,请求直奔数据库,缓存系统形同虚设。缓存雪崩指的是大量的热点数据无法在 Redis 缓存中处理(大面积热点数据缓存失效、Redis 宕机),流量全部打到数据库,导致数据库极大压力。
文章浏览阅读1.2k次。一次命令时间(borrow|return resource + Jedis执行命令(含网络) )的平均耗时约为1ms,一个连接的QPS大约是1000,业务期望的QPS是50000,那么理论上需要的资源池大小是50000 / 1000 = 50个,实际maxTotal可以根据理论值合理进行微调。JedisPool默认的maxTotal=8,下面的代码从JedisPool中借了8次Jedis,但是没有归还,当第9次(jedisPool.getResource().ping())3、发生异常可能的情况。_redis.clients.jedis.exceptions.jedisconnectionexception: could not get a res
文章浏览阅读1k次,点赞27次,收藏18次。在这篇文章中,你将了解到如何在 CentOS 系统上安装 Redis 服务,并且掌握通过自定义域名来访问 Redis 服务的技巧。通过使用自定义域名,你可以方便地管理和访问你的 Redis 数据库,提高工作效率。无论你是开发者、系统管理员还是对 Redis 感兴趣的读者,这篇文章都会为你提供清晰的指导和实用的技巧。阅读本文,轻松搭建自己的 Redis 服务,并体验自定义域名带来的便捷!_redis怎么自定义域名
文章浏览阅读1.1k次,点赞15次,收藏18次。我们post请求,拦截器要预先读取HtppServletRequest里面的body的数据,是通过io的方式,都知道io读取完毕之后,之前的数据是变为null的,但是,当我么后面的接口来委派的时候,也是通过io读取body。我们要考虑一个事情,就是我们要验证数据的重复提交: 首先第一次提交的数据肯定是要被存储的,当而第二次往后,每次提交数据都会与之前的数据产生比对从而验证数据重复提交,我们要具体判断数据是否重复提交的子类。发现数据是成功存入的,剩余7s过期,在10s之内,也就是数据没过期之前,在发送一次。_json.parseobject(str, clazz, auto_type_filter);
文章浏览阅读3.9k次,点赞3次,收藏7次。PHP使用Redis实战实录系列:我们首先检查$redis->connect()方法的返回值来确定是否成功连接到Redis服务器。如果连接失败,我们可以输出相应的错误信息。如果连接成功,我们再执行一些操作,如$redis->set()、$redis->get()等,并检查每个操作的返回结果来判断是否发生了异常。_php redis
文章浏览阅读1.5w次,点赞23次,收藏51次。Redis(Remote Dictionary Server ),即远程字典服务,是一个开源的使用ANSI C语言编写、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库,并提供多种语言的API。Redis 是一个高性能的key-value数据库。redis的出现,很大程度补偿了memcached这类key/value存储的不足,在部 分场合可以对关系数据库起到很好的补充作用。_redisdesktopmanager下载