-
Notifications
You must be signed in to change notification settings - Fork 0
/
8434e219.html
1608 lines (1570 loc) · 274 KB
/
8434e219.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><div id="myscoll"></div><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>Redis学习 | Miaow.Y.Hu的博客🥝</title><meta name="keywords" content="Redis"><meta name="author" content="Miaow.Y.Hu🥝"><meta name="copyright" content="Miaow.Y.Hu🥝"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="ffffff"><meta name="description" content="作为目前最受欢迎的NoSQL,Redis有他的独特之处,并且Redis作为在内存层次的数据库,他的快速和处理相对MySQL来说具有很大的优势,但是其与MySQL各有优势。">
<meta property="og:type" content="article">
<meta property="og:title" content="Redis学习">
<meta property="og:url" content="https://www.blog.909111.xyz/posts/8434e219.html">
<meta property="og:site_name" content="Miaow.Y.Hu的博客🥝">
<meta property="og:description" content="作为目前最受欢迎的NoSQL,Redis有他的独特之处,并且Redis作为在内存层次的数据库,他的快速和处理相对MySQL来说具有很大的优势,但是其与MySQL各有优势。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/luoxiaohei520/MyPics@img/img/202404221531409.jpg">
<meta property="article:published_time" content="2023-11-09T02:50:23.338Z">
<meta property="article:modified_time" content="2024-04-22T08:23:23.411Z">
<meta property="article:author" content="Miaow.Y.Hu🥝">
<meta property="article:tag" content="Redis">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/luoxiaohei520/MyPics@img/img/202404221531409.jpg"><link rel="shortcut icon" href="/"><link rel="canonical" href="https://www.blog.909111.xyz/posts/8434e219"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.staticfile.org/fancyapps-ui/4.0.31/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = {
root: '/',
algolia: undefined,
localSearch: {"path":"/search.xml","preload":true,"languages":{"hits_empty":"找不到您查询的内容:${query}"}},
translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
noticeOutdate: {"limitDay":365,"position":"top","messagePrev":"It has been","messageNext":"days since the last update, the content of the article may be outdated."},
highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":230},
copy: {
success: '复制成功',
error: '复制错误',
noSupport: '浏览器不支持'
},
relativeDate: {
homepage: true,
post: true
},
runtime: '',
date_suffix: {
just: '刚刚',
min: '分钟前',
hour: '小时前',
day: '天前',
month: '个月前'
},
copyright: undefined,
lightbox: 'fancybox',
Snackbar: undefined,
source: {
justifiedGallery: {
js: 'https://cdnjs.cloudflare.com/ajax/libs/flickr-justified-gallery/2.1.2/fjGallery.min.js',
css: 'https://cdnjs.cloudflare.com/ajax/libs/flickr-justified-gallery/2.1.2/fjGallery.min.css'
}
},
isPhotoFigcaption: false,
islazyload: true,
isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
title: 'Redis学习',
isPost: true,
isHome: false,
isHighlightShrink: false,
isToc: true,
postUpdate: '2024-04-22 16:23:23'
}</script><noscript><style type="text/css">
#nav {
opacity: 1
}
.justified-gallery img {
opacity: 1
}
#recent-posts time,
#post-meta time {
display: inline !important
}
</style></noscript><script>(win=>{
win.saveToLocal = {
set: function setWithExpiry(key, value, ttl) {
if (ttl === 0) return
const now = new Date()
const expiryDay = ttl * 86400000
const item = {
value: value,
expiry: now.getTime() + expiryDay,
}
localStorage.setItem(key, JSON.stringify(item))
},
get: function getWithExpiry(key) {
const itemStr = localStorage.getItem(key)
if (!itemStr) {
return undefined
}
const item = JSON.parse(itemStr)
const now = new Date()
if (now.getTime() > item.expiry) {
localStorage.removeItem(key)
return undefined
}
return item.value
}
}
win.getScript = url => new Promise((resolve, reject) => {
const script = document.createElement('script')
script.src = url
script.async = true
script.onerror = reject
script.onload = script.onreadystatechange = function() {
const loadState = this.readyState
if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
script.onload = script.onreadystatechange = null
resolve()
}
document.head.appendChild(script)
})
win.activateDarkMode = function () {
document.documentElement.setAttribute('data-theme', 'dark')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
}
}
win.activateLightMode = function () {
document.documentElement.setAttribute('data-theme', 'light')
if (document.querySelector('meta[name="theme-color"]') !== null) {
document.querySelector('meta[name="theme-color"]').setAttribute('content', 'ffffff')
}
}
const t = saveToLocal.get('theme')
const now = new Date()
const hour = now.getHours()
const isNight = hour <= 6 || hour >= 18
if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
else if (t === 'light') activateLightMode()
else activateDarkMode()
const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
if (asideStatus === 'hide') {
document.documentElement.classList.add('hide-aside')
} else {
document.documentElement.classList.remove('hide-aside')
}
}
const detectApple = () => {
if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
document.documentElement.classList.add('apple')
}
}
detectApple()
})(window)</script><link rel="stylesheet" href="/css/custom.css" media="defer" onload="this.media='all'"><style id="themeColor"></style><style id="rightSide"></style><style id="transPercent"></style><style id="blurNum"></style><style id="settingStyle"></style><span id="fps"></span><style id="defineBg"></style><style id="menu_shadow"></style><link rel="stylesheet" href="/css/universe.css"><link rel="stylesheet" href="https://cdn1.tianli0.top/npm/[email protected]/packages/theme-chalk/lib/index.css"><link rel="stylesheet" href="/css/aplayer.css"><script src="https://npm.elemecdn.com/[email protected]/dist/echarts.min.js"></script><svg aria-hidden="true" style="position:absolute; overflow:hidden; width:0; height:0"><symbol id="icon-sun" viewBox="0 0 1024 1024"><path d="M960 512l-128 128v192h-192l-128 128-128-128H192v-192l-128-128 128-128V192h192l128-128 128 128h192v192z" fill="#FFD878" p-id="8420"></path><path d="M736 512a224 224 0 1 0-448 0 224 224 0 1 0 448 0z" fill="#FFE4A9" p-id="8421"></path><path d="M512 109.248L626.752 224H800v173.248L914.752 512 800 626.752V800h-173.248L512 914.752 397.248 800H224v-173.248L109.248 512 224 397.248V224h173.248L512 109.248M512 64l-128 128H192v192l-128 128 128 128v192h192l128 128 128-128h192v-192l128-128-128-128V192h-192l-128-128z" fill="#4D5152" p-id="8422"></path><path d="M512 320c105.888 0 192 86.112 192 192s-86.112 192-192 192-192-86.112-192-192 86.112-192 192-192m0-32a224 224 0 1 0 0 448 224 224 0 0 0 0-448z" fill="#4D5152" p-id="8423"></path></symbol><symbol id="icon-moon" viewBox="0 0 1024 1024"><path d="M611.370667 167.082667a445.013333 445.013333 0 0 1-38.4 161.834666 477.824 477.824 0 0 1-244.736 244.394667 445.141333 445.141333 0 0 1-161.109334 38.058667 85.077333 85.077333 0 0 0-65.066666 135.722666A462.08 462.08 0 1 0 747.093333 102.058667a85.077333 85.077333 0 0 0-135.722666 65.024z" fill="#FFB531" p-id="11345"></path><path d="M329.728 274.133333l35.157333-35.157333a21.333333 21.333333 0 1 0-30.165333-30.165333l-35.157333 35.157333-35.114667-35.157333a21.333333 21.333333 0 0 0-30.165333 30.165333l35.114666 35.157333-35.114666 35.157334a21.333333 21.333333 0 1 0 30.165333 30.165333l35.114667-35.157333 35.157333 35.157333a21.333333 21.333333 0 1 0 30.165333-30.165333z" fill="#030835" p-id="11346"></path></symbol></svg><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.css" /><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-tag-plugins-plus@latest/lib/assets/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-tag-plugins-plus@latest/lib/tag_plugins.css" media="defer" onload="this.media='all'"><script src="https://npm.elemecdn.com/hexo-butterfly-tag-plugins-plus@latest/lib/assets/carousel-touch.js"></script><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiperstyle.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-wowjs/lib/animate.min.css" media="print" onload="this.media='screen'"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-filter-gitcalendar/lib/gitcalendar.css" media="print" onload="this.media='all'"><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.3.0"><link rel="alternate" href="/atom.xml" title="Miaow.Y.Hu的博客🥝" type="application/atom+xml">
</head><body><div id="loading-box" onclick="document.getElementById("loading-box").classList.add("loaded")"><div class="loading-bg"><div class="loading-img"></div><div class="loading-image-dot"></div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-lazy-src="https://cdn.jsdelivr.net/gh/luoxiaohei520/MyPics@img/img/202404221548536.png" onerror="onerror=null;src='/assets/r1.jpg'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">32</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">19</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">17</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-home"></use></svg><span class="menu_word" style="font-size:17px"> 首页</span></a></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon--article"></use></svg><span class="menu_word" style="font-size:17px"> 文章</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/archives/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-guidang1"> </use></svg><span class="menu_word" style="font-size:17px"> 归档</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/tags/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-sekuaibiaoqian"> </use></svg><span class="menu_word" style="font-size:17px"> 标签</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/categories/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-fenlei"> </use></svg><span class="menu_word" style="font-size:17px"> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-pinweishenghuo"></use></svg><span class="menu_word" style="font-size:17px"> 休闲</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/life/music/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-yinle"> </use></svg><span class="menu_word" style="font-size:17px"> 八音盒</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/life/movies/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-dianying1"> </use></svg><span class="menu_word" style="font-size:17px"> 影院</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/life/games/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-youxishoubing"> </use></svg><span class="menu_word" style="font-size:17px"> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-xiangzi"></use></svg><span class="menu_word" style="font-size:17px"> 八宝箱</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/box/gallery/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-tubiaozhizuomoban"> </use></svg><span class="menu_word" style="font-size:17px"> 画廊</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/box/animation/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-nvwumao"> </use></svg><span class="menu_word" style="font-size:17px"> 动画</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/box/nav/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-zhifengche"> </use></svg><span class="menu_word" style="font-size:17px"> 网址导航</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-shejiaoxinxi"></use></svg><span class="menu_word" style="font-size:17px"> 社交</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/social/fcircle/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-pengyouquan"> </use></svg><span class="menu_word" style="font-size:17px"> 朋友圈</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/comments/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-liuyan"> </use></svg><span class="menu_word" style="font-size:17px"> 留言板</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/social/link/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-lianjie"> </use></svg><span class="menu_word" style="font-size:17px"> 友人帐</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-maoliang"></use></svg><span class="menu_word" style="font-size:17px"> 个人</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/personal/echarts/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-shujutongji1"> </use></svg><span class="menu_word" style="font-size:17px"> 文章统计</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/personal/love/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-love-sign"> </use></svg><span class="menu_word" style="font-size:17px"> 恋爱小屋</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Miaow.Y.Hu的博客🥝</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page faa-parent animated-hover" href="/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-home"></use></svg><span class="menu_word" style="font-size:17px"> 首页</span></a></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon--article"></use></svg><span class="menu_word" style="font-size:17px"> 文章</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/archives/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-guidang1"> </use></svg><span class="menu_word" style="font-size:17px"> 归档</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/tags/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-sekuaibiaoqian"> </use></svg><span class="menu_word" style="font-size:17px"> 标签</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/categories/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-fenlei"> </use></svg><span class="menu_word" style="font-size:17px"> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-pinweishenghuo"></use></svg><span class="menu_word" style="font-size:17px"> 休闲</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/life/music/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-yinle"> </use></svg><span class="menu_word" style="font-size:17px"> 八音盒</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/life/movies/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-dianying1"> </use></svg><span class="menu_word" style="font-size:17px"> 影院</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/life/games/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-youxishoubing"> </use></svg><span class="menu_word" style="font-size:17px"> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-xiangzi"></use></svg><span class="menu_word" style="font-size:17px"> 八宝箱</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/box/gallery/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-tubiaozhizuomoban"> </use></svg><span class="menu_word" style="font-size:17px"> 画廊</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/box/animation/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-nvwumao"> </use></svg><span class="menu_word" style="font-size:17px"> 动画</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/box/nav/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-zhifengche"> </use></svg><span class="menu_word" style="font-size:17px"> 网址导航</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-shejiaoxinxi"></use></svg><span class="menu_word" style="font-size:17px"> 社交</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/social/fcircle/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-pengyouquan"> </use></svg><span class="menu_word" style="font-size:17px"> 朋友圈</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/comments/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-liuyan"> </use></svg><span class="menu_word" style="font-size:17px"> 留言板</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/social/link/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-lianjie"> </use></svg><span class="menu_word" style="font-size:17px"> 友人帐</span></a></li></ul></div><div class="menus_item"><a class="site-page group faa-parent animated-hover hide" href="javascript:void(0);"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-maoliang"></use></svg><span class="menu_word" style="font-size:17px"> 个人</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child faa-parent animated-hover" href="/personal/echarts/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-shujutongji1"> </use></svg><span class="menu_word" style="font-size:17px"> 文章统计</span></a></li><li><a class="site-page child faa-parent animated-hover" href="/personal/love/"><svg class="menu_icon faa-tada" aria-hidden="true" style="width:1.30em;height:1.30em;vertical-align:-0.15em;fill:currentColor;overflow:hidden;"><use xlink:href="#icon-love-sign"> </use></svg><span class="menu_word" style="font-size:17px"> 恋爱小屋</span></a></li></ul></div></div><center id="name-container"><a id="page-name" href="javascript:scrollToTop()">PAGE_NAME</a></center><div id="nav-right"><div id="search-button"><a class="search faa-parent animated-hover" title="检索站内任何你想要的信息"><svg class="faa-tada icon" style="height:24px;width:24px;fill:currentColor;position:relative;top:6px" aria-hidden="true"><use xlink:href="#icon-valentine_-search-love-find-heart"></use></svg><span> 搜索</span></a></div><a class="meihua faa-parent animated-hover" onclick="toggleWinbox()" title="美化设置-自定义你的风格" id="meihua-button"><svg class="faa-tada icon" style="height:26px;width:26px;fill:currentColor;position:relative;top:8px" aria-hidden="true"><use xlink:href="#icon-tupian1"></use></svg></a><a class="sun_moon faa-parent animated-hover" onclick="switchNightMode()" title="浅色和深色模式转换" id="nightmode-button"><svg class="faa-tada" style="height:25px;width:25px;fill:currentColor;position:relative;top:7px" viewBox="0 0 1024 1024"><use id="modeicon" xlink:href="#icon-moon"> </use></svg></a><div id="toggle-menu"><a><i class="fas fa-bars fa-fw"></i></a></div></div></div></nav><div id="post-info"><h1 class="post-title">Redis学习</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><svg class="meta_icon post-meta-icon" style="width:30px;height:30px;position:relative;top:10px"><use xlink:href="#icon-rili"></use></svg><span class="post-meta-label">发表于 </span><time class="post-meta-date-created" datetime="2023-11-09T02:50:23.338Z" title="发表于 2023-11-09 10:50:23">2023-11-09</time><span class="post-meta-separator">|</span><svg class="meta_icon post-meta-icon" style="width:18px;height:18px;position:relative;top:5px"><use xlink:href="#icon-gengxin1"></use></svg><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-04-22T08:23:23.411Z" title="更新于 2024-04-22 16:23:23">2024-04-22</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><svg class="meta_icon post-meta-icon" style="width:18px;height:18px;position:relative;top:5px"><use xlink:href="#icon-biaoqian"></use></svg><a class="post-meta-categories" href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/">数据库</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><svg class="meta_icon post-meta-icon" style="width:25px;height:25px;position:relative;top:8px"><use xlink:href="#icon-charuword"></use></svg><span class="post-meta-label">字数总计:</span><span class="word-count">1.5w</span><span class="post-meta-separator">|</span><svg class="meta_icon post-meta-icon" style="width:20px;height:20px;position:relative;top:5px"><use xlink:href="#icon-shizhong"></use></svg><span class="post-meta-label">阅读时长:</span><span>56分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Redis学习"><svg class="meta_icon post-meta-icon" style="width:25px;height:25px;position:relative;top:5px"><use xlink:href="#icon-eye"></use></svg><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div><section class="main-hero-waves-area waves-area"><svg class="waves-svg" xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M -160 44 c 30 0 58 -18 88 -18 s 58 18 88 18 s 58 -18 88 -18 s 58 18 88 18 v 44 h -352 Z"></path></defs><g class="parallax"><use href="#gentle-wave" x="48" y="0"></use><use href="#gentle-wave" x="48" y="3"></use><use href="#gentle-wave" x="48" y="5"></use><use href="#gentle-wave" x="48" y="7"></use></g></svg></section></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Redis学习"><a href="#Redis学习" class="headerlink" title="Redis学习"></a>Redis学习</h1><p>redis是一个NoSql的(远程字典服务的,key_value的数据库)</p>
<p><strong>redis 能干嘛</strong></p>
<ol>
<li>内存存储,持久化,内存中是断电就失去,所有说持久化很重要</li>
<li>效率高,可以用于高速缓存</li>
<li>发布订阅系统</li>
<li>地图信息统计</li>
<li>计时器,记数器</li>
<li>。。。。</li>
</ol>
<blockquote>
<p>特性</p>
</blockquote>
<ol>
<li>多样的数据类型(HashMap ,set ,String ,List ,Zset)</li>
<li>持久化</li>
<li>集群</li>
<li>事务</li>
<li>。。。。</li>
</ol>
<blockquote>
<p>如何去学习redis</p>
</blockquote>
<p>redis官网 : <a target="_blank" rel="noopener" href="https://www.redis.net.cn/">https://www.redis.net.cn/</a></p>
<p>安装Redis : 这里不写</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br></pre></td><td class="code"><pre><span class="line">下载redis </span><br><span class="line">docker pull redis</span><br><span class="line"></span><br><span class="line">创建实例并启动</span><br><span class="line">mkdir <span class="operator">-</span>p <span class="operator">/</span>mydata<span class="operator">/</span>redis<span class="operator">/</span>conf </span><br><span class="line"></span><br><span class="line">touch redis.conf</span><br><span class="line"></span><br><span class="line">docker run <span class="operator">-</span>p <span class="number">6379</span>:<span class="number">6379</span> <span class="comment">--name redis -v /mydata/redis/data:/data \</span></span><br><span class="line"> <span class="operator">-</span>v <span class="operator">/</span>mydata<span class="operator">/</span>redis<span class="operator">/</span>conf<span class="operator">/</span>redis.conf:<span class="operator">/</span>etc<span class="operator">/</span>redis<span class="operator">/</span>redis.conf \</span><br><span class="line"> <span class="operator">-</span>d redis redis<span class="operator">-</span>server <span class="operator">/</span>etc<span class="operator">/</span>redis<span class="operator">/</span>redis.conf</span><br><span class="line"></span><br><span class="line"> ls 查看当前文件夹下的文件</span><br><span class="line"> cat redis.conf</span><br><span class="line"></span><br><span class="line"> 测试redis </span><br><span class="line"> </span><br><span class="line"> docker <span class="keyword">exec</span> <span class="operator">-</span>it redis redis<span class="operator">-</span>cli</span><br><span class="line"> </span><br><span class="line"> <span class="comment">---</span></span><br><span class="line"> 由于以前的数据全存在内存中,从而我们重复读取<span class="keyword">get</span> a的时候会导致失败</span><br><span class="line">[root<span class="variable">@localhost</span> conf]# cat redis.conf</span><br><span class="line">[root<span class="variable">@localhost</span> conf]# docker <span class="keyword">exec</span> <span class="operator">-</span>it redis redis<span class="operator">-</span>cli</span><br><span class="line"><span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span>:<span class="number">6379</span><span class="operator">></span> <span class="keyword">set</span> a b</span><br><span class="line">OK</span><br><span class="line"><span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span>:<span class="number">6379</span><span class="operator">></span> <span class="keyword">get</span> a</span><br><span class="line">"b" <span class="operator">/</span><span class="operator">/</span>从而在一次上来的时候这块是<span class="keyword">null</span></span><br><span class="line"><span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span>:<span class="number">6379</span><span class="operator">></span> exit</span><br><span class="line"></span><br><span class="line"><span class="comment">--让redis 持久化 ---> pwd</span></span><br><span class="line"><span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span>:<span class="number">6379</span><span class="operator">></span> exit</span><br><span class="line">[root<span class="variable">@localhost</span> conf]# pwd</span><br><span class="line"><span class="operator">/</span>mydata<span class="operator">/</span>redis<span class="operator">/</span>conf</span><br><span class="line">[root<span class="variable">@localhost</span> conf]# ls</span><br><span class="line">redis.conf</span><br><span class="line">[root<span class="variable">@localhost</span> conf]# vi redis.conf </span><br><span class="line">i</span><br><span class="line">appendonly yes</span><br><span class="line">esc :wq</span><br><span class="line"> <span class="comment">--由于进入文档后我不知道如何保存,故此我不在继续持久化了 事实上最新的redis自带持久化了</span></span><br><span class="line"></span><br><span class="line">docker restart redis <span class="operator">/</span><span class="operator">/</span>重启redis</span><br><span class="line"><span class="comment">--设置开机自启动docker 里边容器</span></span><br><span class="line">sudo docker <span class="keyword">update</span> <span class="operator"><</span>容器名<span class="operator">></span> <span class="comment">--restart=always</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="Redis的基础知识"><a href="#Redis的基础知识" class="headerlink" title="Redis的基础知识"></a>Redis的基础知识</h2><p><code>select</code> 选择数据库</p>
<p><code>keys *</code> 查看所有的key</p>
<p><code>exists</code> key 查看key是否存在</p>
<p><code>move key id</code> 根据id和key值移除</p>
<p><code>flushdb</code> 清除当前数据库</p>
<p><code>flushAll</code> 清除全部数据库中所有数据</p>
<p><code>set key value</code> 设置Key和value</p>
<p><code>get key</code> 获得key的值</p>
<p><code>expire key 时间</code> 设置过期时间单位秒</p>
<p><code>ttl key</code> 查看过期时间</p>
<p><code>type key</code> 查看当前key存到value的数据类型</p>
<p>为什么redis端口号为6379。(作者使用一个明星的名字)</p>
<blockquote>
<p>redis是单线程的</p>
</blockquote>
<p>由于redis很快,官方认为,redis是基于内存操作,CPU并不是Redis的性能瓶颈,Redis的瓶颈是根据机械的内存和网络带宽,既然可以使用单线程来实现,那么就使用单线程了。</p>
<h3 id="Redis为啥使用单线程还是这么快?"><a href="#Redis为啥使用单线程还是这么快?" class="headerlink" title="Redis为啥使用单线程还是这么快?"></a>Redis为啥使用单线程还是这么快?</h3><ol>
<li><p>误区,高性能的服务器不一点全是多线程的。</p>
</li>
<li><p>误区2,多线程并不一定都比单线程效率高。</p>
<blockquote>
<p>redis是将数据存放在内存中的,故而使用单线程去操作就比较快,多线程会进行CPU上下文切换,耗时,对于内存系统来说,如果没有上下文切换效率就是最高的,多次读写都是在一个cpu上,在内存情况下,这个就是最佳方案。</p>
</blockquote>
</li>
</ol>
<h3 id="Redis指令大全"><a href="#Redis指令大全" class="headerlink" title="Redis指令大全"></a>Redis指令大全</h3><h4 id="Redis-Key"><a href="#Redis-Key" class="headerlink" title="Redis-Key"></a>Redis-Key</h4><p><code>select</code> 选择数据库</p>
<p><code>keys *</code> 查看所有的key</p>
<p><code>exists</code> key 查看key是否存在</p>
<p><code>move key id</code> 根据id和key值移除</p>
<p><code>flushdb</code> 清除当前数据库</p>
<p><code>flushAll</code> 清除全部数据库中所有数据</p>
<p><code>set key value</code> 设置Key和value</p>
<p><code>get key</code> 获得key的值</p>
<p><code>expire key 时间</code> 设置过期时间单位秒</p>
<p><code>ttl key</code> 查看过期时间</p>
<p><code>type key</code> 查看当前key存到value的数据类型</p>
<p><code>incr key</code>每次执行都进行加一操作</p>
<p><code>desc key</code> 每次执行都进行减一操作</p>
<p><code>getRange key 0 3</code> 截取字符串【0,3】</p>
<p><code>getRange key 0 -1</code> 截取全部的字符串和get key 是一样的</p>
<p><code>setrange key 1 xx</code> 替换指定位置开始的字符串</p>
<p><code>settex (set with expire) key 过期时间 value</code> 设置过期时间且值为value</p>
<p><code>setnx (set if not expire) key</code> 不存在的时候设置(在分布式中会经常使用)也就是说,不存在的时候会自动创建一个key,如果他存在的话,那么就会创建失败</p>
<p><code>mset key1 value1 key2 value2 ...</code> 可以创建多对key和value</p>
<p><code>mget key1 key2 key3 ...</code>可以同时获取多个值</p>
<p><code>msetnx k1 v1 k2 v2 ...</code>是一个原子性操作,要么一起成功,要么一起失败。</p>
<h3 id="Redis的数据类型(String-hash-list-set-zset)"><a href="#Redis的数据类型(String-hash-list-set-zset)" class="headerlink" title="Redis的数据类型(String,hash,list,set,zset)"></a>Redis的数据类型(String,hash,list,set,zset)</h3><p>Redis是一个开源(BSD许可),内存存储的数据结构服务器,可用作数据库,高速缓存和消息队列代理。它支持<a target="_blank" rel="noopener" href="https://www.redis.net.cn/tutorial/3508.html">字符串</a>、<a target="_blank" rel="noopener" href="https://www.redis.net.cn/tutorial/3509.html">哈希表</a>、<a target="_blank" rel="noopener" href="https://www.redis.net.cn/tutorial/3510.html">列表</a>、<a target="_blank" rel="noopener" href="https://www.redis.net.cn/tutorial/3511.html">集合</a>、<a target="_blank" rel="noopener" href="https://www.redis.net.cn/tutorial/3512.html">有序集合</a>,<a target="_blank" rel="noopener" href="https://www.redis.net.cn/tutorial/3508.html">位图</a>,<a target="_blank" rel="noopener" href="https://www.redis.net.cn/tutorial/3513.html">hyperloglogs</a>等数据类型。内置复制、<a target="_blank" rel="noopener" href="https://www.redis.net.cn/tutorial/3516.html">Lua脚本</a>、LRU收回、<a target="_blank" rel="noopener" href="https://www.redis.net.cn/tutorial/3515.html">事务</a>以及不同级别磁盘持久化功能,同时通过Redis Sentinel提供高可用,通过Redis Cluster提供自动<a target="_blank" rel="noopener" href="https://www.redis.net.cn/tutorial/3524.html">分区</a>。 </p>
<h4 id="Redis-键-key-命令"><a href="#Redis-键-key-命令" class="headerlink" title="Redis 键(key) 命令"></a>Redis 键(key) 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Type 命令</td>
<td>返回 key 所储存的值的类型。</td>
</tr>
<tr>
<td>PEXPIREAT</td>
<td>设置 key 的过期时间亿以毫秒计。</td>
</tr>
<tr>
<td>PEXPIREAT</td>
<td>设置 key 过期时间的时间戳(unix timestamp) 以毫秒计</td>
</tr>
<tr>
<td>Rename</td>
<td>修改 key 的名称</td>
</tr>
<tr>
<td>PERSIST</td>
<td>移除 key 的过期时间,key 将持久保持。</td>
</tr>
<tr>
<td>Move</td>
<td>将当前数据库的 key 移动到给定的数据库 db 当中。</td>
</tr>
<tr>
<td>RANDOMKEY</td>
<td>从当前数据库中随机返回一个 key 。</td>
</tr>
<tr>
<td>Dump</td>
<td>序列化给定 key ,并返回被序列化的值。</td>
</tr>
<tr>
<td>TTL</td>
<td>以秒为单位,返回给定 key 的剩余生存时间(TTL, time to live)。</td>
</tr>
<tr>
<td>Expire</td>
<td>seconds 为给定 key 设置过期时间。</td>
</tr>
<tr>
<td>DEL</td>
<td>该命令用于在 key 存在是删除 key。</td>
</tr>
<tr>
<td>Pttl</td>
<td>以毫秒为单位返回 key 的剩余的过期时间。</td>
</tr>
<tr>
<td>Renamenx</td>
<td>仅当 newkey 不存在时,将 key 改名为 newkey 。</td>
</tr>
<tr>
<td>EXISTS</td>
<td>检查给定 key 是否存在。</td>
</tr>
<tr>
<td>Expireat</td>
<td>EXPIREAT 的作用和 EXPIRE 类似,都用于为 key 设置过期时间。 不同在于 EXPIREAT 命令接受的时间参数是 UNIX 时间戳(unix timestamp)。</td>
</tr>
<tr>
<td>Keys</td>
<td>找所有符合给定模式( pattern)的 key 。</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-字符串-String-命令"><a href="#Redis-字符串-String-命令" class="headerlink" title="Redis 字符串(String) 命令"></a>Redis 字符串(String) 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Setnx</td>
<td>只有在 key 不存在时设置 key 的值。</td>
</tr>
<tr>
<td>Getrange</td>
<td>返回 key 中字符串值的子字符</td>
</tr>
<tr>
<td>Mset</td>
<td>同时设置一个或多个 key-value 对。</td>
</tr>
<tr>
<td>Setex</td>
<td>将值 value 关联到 key ,并将 key 的过期时间设为 seconds (以秒为单位)。</td>
</tr>
<tr>
<td>SET</td>
<td>设置指定 key 的值</td>
</tr>
<tr>
<td>Get</td>
<td>获取指定 key 的值。</td>
</tr>
<tr>
<td>Getbit</td>
<td>对 key 所储存的字符串值,获取指定偏移量上的位(bit)。</td>
</tr>
<tr>
<td>Setbit</td>
<td>对 key 所储存的字符串值,设置或清除指定偏移量上的位(bit)。</td>
</tr>
<tr>
<td>Decr</td>
<td>将 key 中储存的数字值减一。</td>
</tr>
<tr>
<td>Decrby</td>
<td>key 所储存的值减去给定的减量值(decrement) 。</td>
</tr>
<tr>
<td>Strlen</td>
<td>返回 key 所储存的字符串值的长度。</td>
</tr>
<tr>
<td>Msetnx</td>
<td>同时设置一个或多个 key-value 对,当且仅当所有给定 key 都不存在。</td>
</tr>
<tr>
<td>Incrby</td>
<td>将 key 所储存的值加上给定的增量值(increment) 。</td>
</tr>
<tr>
<td>Incrbyfloat</td>
<td>将 key 所储存的值加上给定的浮点增量值(increment) 。</td>
</tr>
<tr>
<td>Setrange</td>
<td>用 value 参数覆写给定 key 所储存的字符串值,从偏移量 offset 开始。</td>
</tr>
<tr>
<td>Psetex</td>
<td>这个命令和 SETEX 命令相似,但它以毫秒为单位设置 key 的生存时间,而不是像 SETEX 命令那样,以秒为单位。</td>
</tr>
<tr>
<td>Append</td>
<td>如果 key 已经存在并且是一个字符串, APPEND 命令将 value 追加到 key 原来的值的末尾。</td>
</tr>
<tr>
<td>Getset</td>
<td>将给定 key 的值设为 value ,并返回 key 的旧值(old value)。</td>
</tr>
<tr>
<td>Mget</td>
<td>获取所有(一个或多个)给定 key 的值。</td>
</tr>
<tr>
<td>Incr</td>
<td>将 key 中储存的数字值增一。</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-哈希-Hash-命令"><a href="#Redis-哈希-Hash-命令" class="headerlink" title="Redis 哈希(Hash) 命令"></a>Redis 哈希(Hash) 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Hmset</td>
<td>同时将多个 field-value (域-值)对设置到哈希表 key 中。</td>
</tr>
<tr>
<td>Hmget</td>
<td>获取所有给定字段的值</td>
</tr>
<tr>
<td>Hset</td>
<td>将哈希表 key 中的字段 field 的值设为 value 。</td>
</tr>
<tr>
<td>Hgetall</td>
<td>获取在哈希表中指定 key 的所有字段和值</td>
</tr>
<tr>
<td>Hget</td>
<td>获取存储在哈希表中指定字段的值/td></td>
</tr>
<tr>
<td>Hexists</td>
<td>查看哈希表 key 中,指定的字段是否存在。</td>
</tr>
<tr>
<td>Hincrby</td>
<td>为哈希表 key 中的指定字段的整数值加上增量 increment 。</td>
</tr>
<tr>
<td>Hlen</td>
<td>获取哈希表中字段的数量</td>
</tr>
<tr>
<td>Hdel</td>
<td>删除一个或多个哈希表字段</td>
</tr>
<tr>
<td>Hvals</td>
<td>获取哈希表中所有值</td>
</tr>
<tr>
<td>Hincrbyfloat</td>
<td>为哈希表 key 中的指定字段的浮点数值加上增量 increment 。</td>
</tr>
<tr>
<td>Hkeys</td>
<td>获取所有哈希表中的字段</td>
</tr>
<tr>
<td>Hsetnx</td>
<td>只有在字段 field 不存在时,设置哈希表字段的值。</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-列表-List-命令"><a href="#Redis-列表-List-命令" class="headerlink" title="Redis 列表(List) 命令"></a>Redis 列表(List) 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Lindex</td>
<td>通过索引获取列表中的元素</td>
</tr>
<tr>
<td>Rpush</td>
<td>在列表中添加一个或多个值</td>
</tr>
<tr>
<td>Lrange</td>
<td>获取列表指定范围内的元素</td>
</tr>
<tr>
<td>Rpoplpush</td>
<td>移除列表的最后一个元素,并将该元素添加到另一个列表并返回</td>
</tr>
<tr>
<td>Blpop</td>
<td>移出并获取列表的第一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。</td>
</tr>
<tr>
<td>Brpop</td>
<td>移出并获取列表的最后一个元素, 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。</td>
</tr>
<tr>
<td>Brpoplpush</td>
<td>从列表中弹出一个值,将弹出的元素插入到另外一个列表中并返回它; 如果列表没有元素会阻塞列表直到等待超时或发现可弹出元素为止。</td>
</tr>
<tr>
<td>Lrem</td>
<td>移除列表元素</td>
</tr>
<tr>
<td>Llen</td>
<td>获取列表长度</td>
</tr>
<tr>
<td>Ltrim</td>
<td>对一个列表进行修剪(trim),就是说,让列表只保留指定区间内的元素,不在指定区间之内的元素都将被删除。</td>
</tr>
<tr>
<td>Lpop</td>
<td>出并获取列表的第一个元素</td>
</tr>
<tr>
<td>Lpushx</td>
<td>将一个或多个值插入到已存在的列表头部</td>
</tr>
<tr>
<td>Linsert</td>
<td>在列表的元素前或者后插入元素</td>
</tr>
<tr>
<td>Rpop</td>
<td>移除并获取列表最后一个元素</td>
</tr>
<tr>
<td>Lset</td>
<td>通过索引设置列表元素的值</td>
</tr>
<tr>
<td>Lpush</td>
<td>将一个或多个值插入到列表头部</td>
</tr>
<tr>
<td>Rpushx</td>
<td>为已存在的列表添加值</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-集合-Set-命令"><a href="#Redis-集合-Set-命令" class="headerlink" title="Redis 集合(Set) 命令"></a>Redis 集合(Set) 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sunion</td>
<td>返回所有给定集合的并集</td>
</tr>
<tr>
<td>Scard</td>
<td>获取集合的成员数</td>
</tr>
<tr>
<td>Srandmember</td>
<td>返回集合中一个或多个随机数</td>
</tr>
<tr>
<td>Smembers</td>
<td>返回集合中的所有成员</td>
</tr>
<tr>
<td>Sinter</td>
<td>返回给定所有集合的交集</td>
</tr>
<tr>
<td>Srem</td>
<td>除集合中一个或多个成员</td>
</tr>
<tr>
<td>Smove</td>
<td>将 member 元素从 source 集合移动到 destination 集合</td>
</tr>
<tr>
<td>Sadd</td>
<td>向集合添加一个或多个成员</td>
</tr>
<tr>
<td>Sismember</td>
<td>判断 member 元素是否是集合 key 的成员</td>
</tr>
<tr>
<td>Sdiffstore</td>
<td>返回给定所有集合的差集并存储在 destination 中</td>
</tr>
<tr>
<td>Sdiff</td>
<td>返回给定所有集合的差集</td>
</tr>
<tr>
<td>Sscan</td>
<td>迭代集合中的元素</td>
</tr>
<tr>
<td>Sinterstore</td>
<td>返回给定所有集合的交集并存储在 destination 中</td>
</tr>
<tr>
<td>Sunionstore</td>
<td>所有给定集合的并集存储在 destination 集合中</td>
</tr>
<tr>
<td>Spop</td>
<td>移除并返回集合中的一个随机元素</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-有序集合-sorted-set-命令"><a href="#Redis-有序集合-sorted-set-命令" class="headerlink" title="Redis 有序集合(sorted set) 命令"></a>Redis 有序集合(sorted set) 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Zrevrank</td>
<td>返回有序集合中指定成员的排名,有序集成员按分数值递减(从大到小)排序</td>
</tr>
<tr>
<td>Zlexcount</td>
<td>在有序集合中计算指定字典区间内成员数量</td>
</tr>
<tr>
<td>Zunionstore</td>
<td>计算给定的一个或多个有序集的并集,并存储在新的 key 中</td>
</tr>
<tr>
<td>Zremrangebyrank</td>
<td>移除有序集合中给定的排名区间的所有成员</td>
</tr>
<tr>
<td>Zcard</td>
<td>获取有序集合的成员数</td>
</tr>
<tr>
<td>Zrem</td>
<td>移除有序集合中的一个或多个成员</td>
</tr>
<tr>
<td>Zinterstore</td>
<td>计算给定的一个或多个有序集的交集并将结果集存储在新的有序集合 key 中</td>
</tr>
<tr>
<td>Zrank</td>
<td>返回有序集合中指定成员的索引</td>
</tr>
<tr>
<td>Zincrby</td>
<td>有序集合中对指定成员的分数加上增量 increment</td>
</tr>
<tr>
<td>Zrangebyscore</td>
<td>通过分数返回有序集合指定区间内的成员</td>
</tr>
<tr>
<td>Zrangebylex</td>
<td>通过字典区间返回有序集合的成员</td>
</tr>
<tr>
<td>Zscore</td>
<td>返回有序集中,成员的分数值</td>
</tr>
<tr>
<td>Zremrangebyscore</td>
<td>移除有序集合中给定的分数区间的所有成员</td>
</tr>
<tr>
<td>Zscan</td>
<td>迭代有序集合中的元素(包括元素成员和元素分值)</td>
</tr>
<tr>
<td>Zrevrangebyscore</td>
<td>返回有序集中指定分数区间内的成员,分数从高到低排序</td>
</tr>
<tr>
<td>Zremrangebylex</td>
<td>移除有序集合中给定的字典区间的所有成员</td>
</tr>
<tr>
<td>Zrevrange</td>
<td>返回有序集中指定区间内的成员,通过索引,分数从高到底</td>
</tr>
<tr>
<td>Zrange</td>
<td>通过索引区间返回有序集合成指定区间内的成员</td>
</tr>
<tr>
<td>Zcount</td>
<td>计算在有序集合中指定区间分数的成员数</td>
</tr>
<tr>
<td>Zadd</td>
<td>向有序集合添加一个或多个成员,或者更新已存在成员的分数</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-连接-命令"><a href="#Redis-连接-命令" class="headerlink" title="Redis 连接 命令"></a>Redis 连接 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Echo</td>
<td>打印字符串</td>
</tr>
<tr>
<td>Select</td>
<td>切换到指定的数据库</td>
</tr>
<tr>
<td>Ping</td>
<td>查看服务是否运行</td>
</tr>
<tr>
<td>Quit</td>
<td>关闭当前连接</td>
</tr>
<tr>
<td>Auth</td>
<td>验证密码是否正确</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-服务器-命令"><a href="#Redis-服务器-命令" class="headerlink" title="Redis 服务器 命令"></a>Redis 服务器 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Client Pause</td>
<td>在指定时间内终止运行来自客户端的命令</td>
</tr>
<tr>
<td>Debug Object</td>
<td>获取 key 的调试信息</td>
</tr>
<tr>
<td>Flushdb</td>
<td>删除当前数据库的所有key</td>
</tr>
<tr>
<td>Save</td>
<td>异步保存数据到硬盘</td>
</tr>
<tr>
<td>Showlog</td>
<td>管理 redis 的慢日志</td>
</tr>
<tr>
<td>Lastsave</td>
<td>返回最近一次 Redis 成功将数据保存到磁盘上的时间,以 UNIX 时间戳格式表示</td>
</tr>
<tr>
<td>Config Get</td>
<td>获取指定配置参数的值</td>
</tr>
<tr>
<td>Command</td>
<td>获取 Redis 命令详情数组</td>
</tr>
<tr>
<td>Slaveof</td>
<td>将当前服务器转变为指定服务器的从属服务器(slave server)</td>
</tr>
<tr>
<td>Debug Segfault</td>
<td>让 Redis 服务崩溃</td>
</tr>
<tr>
<td>Flushall</td>
<td>删除所有数据库的所有key</td>
</tr>
<tr>
<td>Dbsize</td>
<td>返回当前数据库的 key 的数量</td>
</tr>
<tr>
<td>Bgrewriteaof</td>
<td>异步执行一个 AOF(AppendOnly File) 文件重写操作</td>
</tr>
<tr>
<td>Cluster Slots</td>
<td>获取集群节点的映射数组</td>
</tr>
<tr>
<td>Config Set</td>
<td>修改 redis 配置参数,无需重启</td>
</tr>
<tr>
<td>Command Info</td>
<td>获取指定 Redis 命令描述的数组</td>
</tr>
<tr>
<td>Shutdown</td>
<td>异步保存数据到硬盘,并关闭服务器</td>
</tr>
<tr>
<td>Sync</td>
<td>用于复制功能(replication)的内部命令</td>
</tr>
<tr>
<td>Client Kill</td>
<td>关闭客户端连接</td>
</tr>
<tr>
<td>Role</td>
<td>返回主从实例所属的角色</td>
</tr>
<tr>
<td>Monitor</td>
<td>实时打印出 Redis 服务器接收到的命令,调试用</td>
</tr>
<tr>
<td>Command Getkeys</td>
<td>获取给定命令的所有键</td>
</tr>
<tr>
<td>Client Getname</td>
<td>获取连接的名称</td>
</tr>
<tr>
<td>Config Resetstat</td>
<td>重置 INFO 命令中的某些统计数据</td>
</tr>
<tr>
<td>Command Count</td>
<td>获取 Redis 命令总数</td>
</tr>
<tr>
<td>Time</td>
<td>返回当前服务器时间</td>
</tr>
<tr>
<td>Info</td>
<td>获取 Redis 服务器的各种信息和统计数值</td>
</tr>
<tr>
<td>Config rewrite</td>
<td>对启动 Redis 服务器时所指定的 redis.conf 配置文件进行改写</td>
</tr>
<tr>
<td>Client List</td>
<td>获取连接到服务器的客户端连接列表</td>
</tr>
<tr>
<td>Client Setname</td>
<td>设置当前连接的名称</td>
</tr>
<tr>
<td>Bgsave</td>
<td>在后台异步保存当前数据库的数据到磁盘</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-脚本-命令"><a href="#Redis-脚本-命令" class="headerlink" title="Redis 脚本 命令"></a>Redis 脚本 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Script kill</td>
<td>杀死当前正在运行的 Lua 脚本。</td>
</tr>
<tr>
<td>Script Load</td>
<td>将脚本 script 添加到脚本缓存中,但并不立即执行这个脚本。</td>
</tr>
<tr>
<td>Eval</td>
<td>执行 Lua 脚本。</td>
</tr>
<tr>
<td>Evalsha</td>
<td>执行 Lua 脚本。</td>
</tr>
<tr>
<td>Script Exists</td>
<td>查看指定的脚本是否已经被保存在缓存当中。</td>
</tr>
<tr>
<td>Script Flush</td>
<td>从脚本缓存中移除所有脚本。</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-事务-命令"><a href="#Redis-事务-命令" class="headerlink" title="Redis 事务 命令"></a>Redis 事务 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Exec</td>
<td>执行所有事务块内的命令。</td>
</tr>
<tr>
<td>Watch</td>
<td>监视一个(或多个) key ,如果在事务执行之前这个(或这些) key 被其他命令所改动,那么事务将被打断。</td>
</tr>
<tr>
<td>Discard</td>
<td>取消事务,放弃执行事务块内的所有命令。</td>
</tr>
<tr>
<td>Unwatch</td>
<td>取消 WATCH 命令对所有 key 的监视。</td>
</tr>
<tr>
<td>Multi</td>
<td>标记一个事务块的开始。</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-HyperLogLog-命令"><a href="#Redis-HyperLogLog-命令" class="headerlink" title="Redis HyperLogLog 命令"></a>Redis HyperLogLog 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Pgmerge</td>
<td>将多个 HyperLogLog 合并为一个 HyperLogLog</td>
</tr>
<tr>
<td>Pfadd</td>
<td>添加指定元素到 HyperLogLog 中。</td>
</tr>
<tr>
<td>Pfcount</td>
<td>返回给定 HyperLogLog 的基数估算值。</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-发布订阅-命令"><a href="#Redis-发布订阅-命令" class="headerlink" title="Redis 发布订阅 命令"></a>Redis 发布订阅 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>
</tr>
</thead>
<tbody>
<tr>
<td>Unsubscribe</td>
<td>指退订给定的频道。</td>
</tr>
<tr>
<td>Subscribe</td>
<td>订阅给定的一个或多个频道的信息。</td>
</tr>
<tr>
<td>Pubsub</td>
<td>查看订阅与发布系统状态。</td>
</tr>
<tr>
<td>Punsubscribe</td>
<td>退订所有给定模式的频道。</td>
</tr>
<tr>
<td>Publish</td>
<td>将信息发送到指定的频道。</td>
</tr>
<tr>
<td>Psubscribe</td>
<td>订阅一个或多个符合给定模式的频道。</td>
</tr>
</tbody>
</table>
</div>
<h4 id="Redis-地理位置-geo-命令"><a href="#Redis-地理位置-geo-命令" class="headerlink" title="Redis 地理位置(geo) 命令"></a>Redis 地理位置(geo) 命令</h4><div class="table-container">
<table>
<thead>
<tr>
<th>命令</th>
<th>描述</th>