{"id":15804,"date":"2026-04-24T03:08:21","date_gmt":"2026-04-23T19:08:21","guid":{"rendered":"https:\/\/top.duoku.icu\/libs\/15804.html"},"modified":"2026-04-24T03:08:21","modified_gmt":"2026-04-23T19:08:21","slug":"redis-%e5%9f%ba%e7%a1%80%e9%85%8d%e7%bd%ae%e4%b8%8e%e4%bd%bf%e7%94%a8%e5%ae%8c%e5%85%a8%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/www.srclibs.com\/index.php\/2026\/04\/24\/redis-%e5%9f%ba%e7%a1%80%e9%85%8d%e7%bd%ae%e4%b8%8e%e4%bd%bf%e7%94%a8%e5%ae%8c%e5%85%a8%e6%8c%87%e5%8d%97\/","title":{"rendered":"Redis \u57fa\u7840\u914d\u7f6e\u4e0e\u4f7f\u7528\u5b8c\u5168\u6307\u5357"},"content":{"rendered":"<h2>Redis \u57fa\u7840\u914d\u7f6e\u4e0e\u4f7f\u7528\u5b8c\u5168\u6307\u5357<\/h2>\n<p>Redis \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u4f7f\u7528 ANSI C \u8bed\u8a00\u7f16\u5199\u3001\u652f\u6301\u7f51\u7edc\u3001\u53ef\u57fa\u4e8e\u5185\u5b58\u4ea6\u53ef\u6301\u4e45\u5316\u7684\u65e5\u5fd7\u578b\u3001Key-Value \u6570\u636e\u5e93\u3002\u672c\u6307\u5357\u5c06\u8be6\u7ec6\u4ecb\u7ecd Redis \u7684\u914d\u7f6e\u3001\u4f7f\u7528\u548c\u6700\u4f73\u5b9e\u8df5\u3002<\/p>\n<h2>\u4e00\u3001Redis \u6838\u5fc3\u6982\u5ff5<\/h2>\n<p>Redis \u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5305\u62ec\u5b57\u7b26\u4e32\u3001\u54c8\u5e0c\u3001\u5217\u8868\u3001\u96c6\u5408\u3001\u6709\u5e8f\u96c6\u5408\u7b49\u3002<\/p>\n<h3>1. \u5b57\u7b26\u4e32\uff08String\uff09<\/h3>\n<p>Redis \u6700\u57fa\u672c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u6700\u5927\u53ef\u4ee5\u5b58\u50a8 512MB\u3002<\/p>\n<h3>2. \u54c8\u5e0c\uff08Hash\uff09<\/h3>\n<p>\u9002\u5408\u5b58\u50a8\u5bf9\u8c61\uff0c\u6bd4\u5982\u7528\u6237\u4fe1\u606f\u3002<\/p>\n<h3>3. \u5217\u8868\uff08List\uff09<\/h3>\n<p>\u7b80\u5355\u7684\u5217\u8868\uff0c\u652f\u6301\u4e24\u7aef push\/pop \u64cd\u4f5c\u3002<\/p>\n<h3>4. \u96c6\u5408\uff08Set\uff09<\/h3>\n<p>\u5b57\u7b26\u4e32\u96c6\u5408\uff0c\u4e0d\u5141\u8bb8\u91cd\u590d\uff0c\u652f\u6301\u4ea4\u96c6\u3001\u5e76\u96c6\u3001\u5dee\u96c6\u64cd\u4f5c\u3002<\/p>\n<h3>5. \u6709\u5e8f\u96c6\u5408\uff08Zset\uff09<\/h3>\n<p>\u5b57\u7b26\u4e32\u96c6\u5408\uff0c\u4e0d\u5141\u8bb8\u91cd\u590d\uff0c\u6bcf\u4e2a\u5143\u7d20\u5173\u8054\u4e00\u4e2a score\uff0c\u7528\u4e8e\u6392\u5e8f\u3002<\/p>\n<h3>6. \u4f4d\u56fe\uff08Bitmap\uff09<\/h3>\n<p>\u57fa\u4e8e\u5b57\u7b26\u4e32\u7684\u4f4d\u64cd\u4f5c\uff0c\u8282\u7701\u7a7a\u95f4\u3002<\/p>\n<h3>7. \u8d85\u7ea7\u57fa\u6570\uff08HyperLogLog\uff09<\/h3>\n<p>\u57fa\u4e8e\u6982\u7387\u7684\u57fa\u6570\u7edf\u8ba1\uff0c\u7a7a\u95f4\u5360\u7528\u56fa\u5b9a\u3002<\/p>\n<div style=\"text-align:center;margin:30px 0;\"><img decoding=\"async\" src=\"https:\/\/top.duoku.icu\/wp-content\/uploads\/2026\/04\/image-19.png\" alt=\"Redis \u67b6\u6784\" style=\"max-width:100%;height:auto;border-radius:12px;box-shadow:0 4px 12px rgba(0,0,0,0.1);\"><\/div>\n<h2>\u4e8c\u3001Redis \u5b89\u88c5\u914d\u7f6e<\/h2>\n<h3>1. \u5b89\u88c5 Redis<\/h3>\n<pre><code># Ubuntu\/Debian\napt-get update\napt-get install redis-server\n\n# CentOS\/RHEL\nyum install redis\n\n# \u7f16\u8bd1\u5b89\u88c5\nwget https:\/\/download.redis.io\/redis-stable.tar.gz\ntar -xzf redis-stable.tar.gz\ncd redis-stable\nmake\nmake install<\/code><\/pre>\n<h3>2. \u914d\u7f6e redis.conf<\/h3>\n<pre><code># \u7ed1\u5b9a\u5730\u5740\nbind 127.0.0.1\n\n# \u7aef\u53e3\nport 6379\n\n# \u4fdd\u62a4\u6a21\u5f0f\nprotected-mode yes\n\n# \u5b88\u62a4\u8fdb\u7a0b\ndaemonize yes\n\n# PID \u6587\u4ef6\npidfile \/var\/run\/redis_6379.pid\n\n# \u65e5\u5fd7\u7ea7\u522b\nloglevel notice\n\n# \u65e5\u5fd7\u6587\u4ef6\nlogfile \/var\/log\/redis.log\n\n# \u6570\u636e\u5e93\u6570\u91cf\ndatabases 16\n\n# RDB \u6301\u4e45\u5316\nsave 900 1\nsave 300 10\nsave 60 10000\n\n# AOF \u6301\u4e45\u5316\nappendonly yes\nappendfilename \"appendonly.aof\"\nappendfsync everysec\n\n# \u6700\u5927\u5185\u5b58\nmaxmemory 256mb\nmaxmemory-policy allkeys-lru\n\n# \u6162\u67e5\u8be2\u65e5\u5fd7\nslowlog-log-slower-than 10000\nslowlog-max-len 128<\/code><\/pre>\n<h3>3. \u542f\u52a8 Redis<\/h3>\n<pre><code># \u4f7f\u7528\u914d\u7f6e\u6587\u4ef6\u542f\u52a8\nredis-server \/etc\/redis\/redis.conf\n\n# \u6216\u4f7f\u7528\u547d\u4ee4\u884c\nredis-server --port 6379 --appendonly yes<\/code><\/pre>\n<h2>\u4e09\u3001Redis \u547d\u4ee4\u884c\u64cd\u4f5c<\/h2>\n<h3>1. \u5b57\u7b26\u4e32\u64cd\u4f5c<\/h3>\n<pre><code># \u8bbe\u7f6e\u548c\u83b7\u53d6\nSET key value\nGET key\n\n# \u6279\u91cf\u64cd\u4f5c\nMSET key1 value1 key2 value2\nMGET key1 key2\n\n# \u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\nSETEX key seconds value\nPTEX key milliseconds value\n\n# \u9012\u589e\u9012\u51cf\nINCR key\nDECR key\nINCRBY key increment\nDECRBY key decrement\n\n# \u83b7\u53d6\u548c\u8bbe\u7f6e\nGETSET key value\nSTRLEN key<\/code><\/pre>\n<h3>2. \u54c8\u5e0c\u64cd\u4f5c<\/h3>\n<pre><code># \u8bbe\u7f6e\u548c\u83b7\u53d6\nHSET key field value\nHGET key field\n\n# \u6279\u91cf\u64cd\u4f5c\nHMSET key field1 value1 field2 value2\nHMGET key field1 field2\n\n# \u5220\u9664\u5b57\u6bb5\nHDEL key field1 field2\n\n# \u83b7\u53d6\u6240\u6709\u5b57\u6bb5\u548c\u503c\nHGETALL key\n\n# \u5224\u65ad\u5b57\u6bb5\u662f\u5426\u5b58\u5728\nHEXISTS key field\n\n# \u83b7\u53d6\u5b57\u6bb5\u6570\u91cf\nHLEN key\n\n# \u8fed\u4ee3\u64cd\u4f5c\nHSCAN key cursor [MATCH pattern] [COUNT count]<\/code><\/pre>\n<h3>3. \u5217\u8868\u64cd\u4f5c<\/h3>\n<pre><code># \u4e24\u7aef\u64cd\u4f5c\nLPUSH key value [value ...]\nRPUSH key value [value ...]\nLPOP key\nRPOP key\n\n# \u6279\u91cf\u64cd\u4f5c\nLPUSHX key value\nRPUSHX key value\n\n# \u83b7\u53d6\u5143\u7d20\nLINDEX key index\nLLEN key\n\n# \u83b7\u53d6\u8303\u56f4\nLRANGE key start stop\n\n# \u5220\u9664\u548c\u4fee\u6539\nLREM key count value\nLSET key index value\nLTRIM key start stop\n\n# \u963b\u585e\u5f0f\u64cd\u4f5c\nBLPOP key [key ...] timeout\nBRPOP key [key ...] timeout<\/code><\/pre>\n<h3>4. \u96c6\u5408\u64cd\u4f5c<\/h3>\n<pre><code># \u6dfb\u52a0\u548c\u5220\u9664\nSADD key member [member ...]\nSREM key member [member ...]\n\n# \u83b7\u53d6\u96c6\u5408\nSMEMBERS key\nSCARD key\n\n# \u5224\u65ad\u6210\u5458\nSISMEMBER key member\n\n# \u5dee\u96c6\u8fd0\u7b97\nSDIFF key [key ...]\nSDIFFSTORE destination key [key ...]\n\n# \u4ea4\u96c6\u8fd0\u7b97\nSINTER key [key ...]\nSINTERSTORE destination key [key ...]\n\n# \u5e76\u96c6\u8fd0\u7b97\nSUNION key [key ...]\nSUNIONSTORE destination key [key ...]\n\n# \u968f\u673a\u83b7\u53d6\nSRANDMEMBER key [count]\n\n# \u79fb\u52a8\u6210\u5458\u5230\u96c6\u5408\nSMOVE source destination member\n\n# \u5f39\u51fa\u4e00\u4e2a\u6210\u5458\nSPOP key [count]<\/code><\/pre>\n<h3>5. \u6709\u5e8f\u96c6\u5408\u64cd\u4f5c<\/h3>\n<pre><code># \u6dfb\u52a0\u6210\u5458\nZADD key score member [score member ...]\n\n# \u83b7\u53d6\u6392\u540d\nZRANGE key start stop [WITHSCORES]\nZREVRANGE key start stop [WITHSCORES]\n\n# \u83b7\u53d6\u5206\u6570\nZSCORE key member\nZMSCORE key member [member ...]\n\n# \u5220\u9664\u6210\u5458\nZREM key member [member ...]\n\n# \u83b7\u53d6\u6570\u91cf\nZCARD key\nZCOUNT key min max\n\n# \u6392\u540d\nZRANK key member\nZREVRANK key member\n\n# \u8303\u56f4\u67e5\u8be2\nZRANGEBYSCORE key min max [WITHSCORES] [LIMIT offset count]\n\n# \u4ea4\u96c6\u548c\u5e76\u96c6\nZUNIONSTORE destination numkeys key [key ...]\nZINTERSTORE destination numkeys key [key ...]<\/code><\/pre>\n<h3>6. \u952e\u64cd\u4f5c<\/h3>\n<pre><code># \u5220\u9664\u952e\nDEL key [key ...]\n\n# \u68c0\u67e5\u662f\u5426\u5b58\u5728\nEXISTS key\n\n# \u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\nEXPIRE key seconds\nPEXPIRE key milliseconds\nEXPIREAT key timestamp\nPEXPIREAT key timestamp\n\n# \u83b7\u53d6\u5269\u4f59\u65f6\u95f4\nTTL key\nPTTL key\n\n# \u79fb\u52a8\u6570\u636e\u5e93\nMOVE key db\n\n# \u91cd\u547d\u540d\nRENAME key newkey\nRENAMENX key newkey\n\n# \u83b7\u53d6\u7c7b\u578b\nTYPE key\n\n# \u514b\u9686\nDUP key<\/code><\/pre>\n<h2>\u56db\u3001Redis \u6301\u4e45\u5316<\/h2>\n<h3>1. RDB \u6301\u4e45\u5316<\/h3>\n<p>\u5feb\u7167\u65b9\u5f0f\uff0c\u5b9a\u671f\u5c06\u6570\u636e\u96c6\u5199\u5165\u78c1\u76d8\u3002<\/p>\n<pre><code># \u914d\u7f6e\u793a\u4f8b\nsave 900 1      # 15 \u5206\u949f\u81f3\u5c11 1 \u4e2a key \u53d8\u5316\nsave 300 10     # 5 \u5206\u949f\u81f3\u5c11 10 \u4e2a key \u53d8\u5316\nsave 60 10000   # 1 \u5206\u949f\u81f3\u5c11 10000 \u4e2a key \u53d8\u5316\n\n# \u89e6\u53d1\u624b\u52a8\u4fdd\u5b58\nSAVE    # \u963b\u585e\u5f0f\nBGSAVE  # \u5f02\u6b65\u5f0f<\/code><\/pre>\n<h3>2. AOF \u6301\u4e45\u5316<\/h3>\n<p>\u8ffd\u52a0\u65e5\u5fd7\uff0c\u8bb0\u5f55\u6bcf\u6b21\u5199\u64cd\u4f5c\u3002<\/p>\n<pre><code># \u914d\u7f6e\u9009\u9879\nappendonly yes\nappendfilename \"appendonly.aof\"\nappendfsync everysec  # \u6bcf\u79d2\u540c\u6b65\nappendfsync always    # \u6bcf\u6b21\u5199\u64cd\u4f5c\u90fd\u540c\u6b65\nappendfsync no        # \u7531\u64cd\u4f5c\u7cfb\u7edf\u51b3\u5b9a\n\n# \u91cd\u5199 AOF \u6587\u4ef6\nBGREWRITEAOF<\/code><\/pre>\n<h3>3. \u6301\u4e45\u5316\u5bf9\u6bd4<\/h3>\n<table border=\"1\" cellpadding=\"5\">\n<tr>\n<th>\u7279\u6027<\/th>\n<th>RDB<\/th>\n<th>AOF<\/th>\n<\/tr>\n<tr>\n<td>\u5b8c\u6574\u6027<\/td>\n<td>\u53ef\u80fd\u4e22\u5931<\/td>\n<td>\u66f4\u5b8c\u6574<\/td>\n<\/tr>\n<tr>\n<td>\u901f\u5ea6<\/td>\n<td>\u66f4\u5feb<\/td>\n<td>\u8f83\u6162<\/td>\n<\/tr>\n<tr>\n<td>\u6587\u4ef6\u5927\u5c0f<\/td>\n<td>\u5c0f<\/td>\n<td>\u5927<\/td>\n<\/tr>\n<tr>\n<td>\u6062\u590d\u901f\u5ea6<\/td>\n<td>\u5feb<\/td>\n<td>\u6162<\/td>\n<\/tr>\n<\/table>\n<h2>\u4e94\u3001Redis \u5185\u5b58\u7ba1\u7406<\/h2>\n<h3>1. \u5185\u5b58\u914d\u7f6e<\/h3>\n<pre><code># \u6700\u5927\u5185\u5b58\nmaxmemory 256mb\n\n# \u5185\u5b58\u7b56\u7565\nmaxmemory-policy allkeys-lru\nmaxmemory-samples 5<\/code><\/pre>\n<h3>2. \u5185\u5b58\u7b56\u7565\u8bf4\u660e<\/h3>\n<table border=\"1\" cellpadding=\"5\">\n<tr>\n<th>\u7b56\u7565<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<tr>\n<td>noeviction<\/td>\n<td>\u4e0d\u6dd8\u6c70\uff0c\u5199\u5165\u8fd4\u56de\u9519\u8bef<\/td>\n<\/tr>\n<tr>\n<td>allkeys-lru<\/td>\n<td>\u6dd8\u6c70\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\u7684\u952e<\/td>\n<\/tr>\n<tr>\n<td>volatile-lru<\/td>\n<td>\u6dd8\u6c70\u8bbe\u7f6e\u4e86 TTL \u7684\u6700\u8fd1\u6700\u5c11\u4f7f\u7528\u7684\u952e<\/td>\n<\/tr>\n<tr>\n<td>allkeys-random<\/td>\n<td>\u968f\u673a\u6dd8\u6c70<\/td>\n<\/tr>\n<tr>\n<td>volatile-random<\/td>\n<td>\u968f\u673a\u6dd8\u6c70\u8bbe\u7f6e TTL \u7684\u952e<\/td>\n<\/tr>\n<tr>\n<td>volatile-ttl<\/td>\n<td>\u6dd8\u6c70\u5373\u5c06\u8fc7\u671f\u7684\u952e<\/td>\n<\/tr>\n<\/table>\n<h3>3. \u76d1\u63a7\u5185\u5b58<\/h3>\n<pre><code># \u67e5\u770b\u5185\u5b58\u4f7f\u7528\nINFO memory\n\n# \u67e5\u770b\u5927\u952e\nKEYS *\nMEMORY USAGE key<\/code><\/pre>\n<h2>\u516d\u3001Redis \u9ad8\u53ef\u7528\u65b9\u6848<\/h2>\n<h3>1. \u4e3b\u4ece\u590d\u5236\uff08Replication\uff09<\/h3>\n<pre><code># \u914d\u7f6e\u4ece\u8282\u70b9\nreplicaof 127.0.0.1 6379\n\n# \u67e5\u770b\u590d\u5236\u72b6\u6001\nINFO replication<\/code><\/pre>\n<h3>2. Sentinel\uff08\u54e8\u5175\uff09<\/h3>\n<p>Redis Sentinel \u63d0\u4f9b\u81ea\u52a8\u6545\u969c\u8f6c\u79fb\u3002<\/p>\n<pre><code># sentinel.conf \u914d\u7f6e\nsentinel monitor mymaster 127.0.0.1 6379 2\nsentinel down-after-milliseconds mymaster 5000\nsentinel failover-timeout mymaster 60000\nsentinel parallel-syncs mymaster 1<\/code><\/pre>\n<h3>3. Cluster\uff08\u96c6\u7fa4\uff09<\/h3>\n<pre><code># \u542f\u52a8\u96c6\u7fa4\nredis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 \\\n  127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 \\\n  --cluster-replicas 1\n\n# \u67e5\u770b\u96c6\u7fa4\u72b6\u6001\nCLUSTER INFO\nCLUSTER NODES<\/code><\/pre>\n<h2>\u4e03\u3001Redis \u5ba2\u6237\u7aef<\/h2>\n<h3>1. Java \u5ba2\u6237\u7aef<\/h3>\n<pre><code>&lt;dependency&gt;\n    &lt;groupId&gt;redis.clients&lt;\/groupId&gt;\n    &lt;artifactId&gt;jedis&lt;\/artifactId&gt;\n    &lt;version&gt;4.3.1&lt;\/version&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n<h3>2. Jedis \u793a\u4f8b<\/h3>\n<pre><code>\/\/ \u8fde\u63a5\u6c60\u914d\u7f6e\nJedisPoolConfig poolConfig = new JedisPoolConfig();\npoolConfig.setMaxTotal(100);\npoolConfig.setMaxIdle(20);\npoolConfig.setMaxWaitMillis(3000);\n\n\/\/ \u521b\u5efa\u8fde\u63a5\u6c60\nJedisPool pool = new JedisPool(poolConfig, \"localhost\", 6379);\n\n\/\/ \u4f7f\u7528\ntry (Jedis jedis = pool.getResource()) {\n    jedis.set(\"key\", \"value\");\n    String value = jedis.get(\"key\");\n}<\/code><\/pre>\n<h3>3. Spring Data Redis<\/h3>\n<pre><code>@Configuration\n@EnableRedisHttpSession\npublic class RedisConfig {\n    \n    @Bean\n    public RedisConnectionFactory connectionFactory() {\n        LettuceConnectionFactory factory = new LettuceConnectionFactory();\n        factory.setHostName(\"localhost\");\n        factory.setPort(6379);\n        return factory;\n    }\n    \n    @Bean\n    public RedisTemplate<String, Object> redisTemplate() {\n        RedisTemplate<String, Object> template = new RedisTemplate<>();\n        template.setConnectionFactory(connectionFactory());\n        template.setKeySerializer(new StringRedisSerializer());\n        template.setValueSerializer(new GenericJackson2JsonRedisSerializer());\n        return template;\n    }\n}<\/code><\/pre>\n<h2>\u516b\u3001Redis \u7f13\u5b58\u4f18\u5316<\/h2>\n<h3>1. \u7f13\u5b58\u7b56\u7565<\/h3>\n<ul>\n<li><strong>Cache Aside<\/strong> &#8211; \u5e94\u7528\u540c\u65f6\u7ba1\u7406\u6570\u636e\u5e93\u548c\u7f13\u5b58<\/li>\n<li><strong>Read\/Write Through<\/strong> &#8211; \u7f13\u5b58\u5c42\u8d1f\u8d23\u6570\u636e\u6301\u4e45\u5316<\/li>\n<li><strong>Write Behind<\/strong> &#8211; \u5f02\u6b65\u5199\u5165\u6570\u636e\u5e93<\/li>\n<\/ul>\n<h3>2. \u7f13\u5b58\u7a7f\u900f<\/h3>\n<p>\u67e5\u8be2\u4e0d\u5b58\u5728\u7684\u6570\u636e\u3002<\/p>\n<pre><code>\u89e3\u51b3\u65b9\u6848\uff1a\n1. \u7f13\u5b58\u7a7a\u5bf9\u8c61\n2. \u5e03\u9686\u8fc7\u6ee4\u5668\u62e6\u622a<\/code><\/pre>\n<h3>3. \u7f13\u5b58\u96ea\u5d29<\/h3>\n<p>\u5927\u91cf\u7f13\u5b58\u540c\u65f6\u8fc7\u671f\u3002<\/p>\n<pre><code>\u89e3\u51b3\u65b9\u6848\uff1a\n1. \u8bbe\u7f6e\u4e0d\u540c\u7684\u8fc7\u671f\u65f6\u95f4\n2. \u4f7f\u7528\u4e92\u65a5\u9501<\/code><\/pre>\n<h3>4. \u7f13\u5b58\u9884\u70ed<\/h3>\n<pre><code>\/\/ \u5e94\u7528\u542f\u52a8\u65f6\u9884\u70ed\u7f13\u5b58\n@PostConstruct\npublic void warmupCache() {\n    List<String> hotKeys = getHotKeys();\n    for (String key : hotKeys) {\n        cache.put(key, loadData(key));\n    }\n}<\/code><\/pre>\n<h3>5. \u70ed\u70b9 Key<\/h3>\n<pre><code>\/\/ \u68c0\u6d4b\u70ed\u70b9 key\nSLOWLOG GET 10\nMONITOR<\/code><\/pre>\n<h2>\u4e5d\u3001Redis \u5b89\u5168\u914d\u7f6e<\/h2>\n<h3>1. \u5bc6\u7801\u8ba4\u8bc1<\/h3>\n<pre><code># redis.conf\nrequirepass your_strong_password<\/code><\/pre>\n<h3>2. \u9650\u5236\u7ed1\u5b9a<\/h3>\n<pre><code>bind 127.0.0.1 192.168.1.100<\/code><\/pre>\n<h3>3. \u7981\u7528\u5371\u9669\u547d\u4ee4<\/h3>\n<pre><code># \u91cd\u547d\u540d\u6216\u5220\u9664\u5371\u9669\u547d\u4ee4\nrename-command FLUSHDB \"\"\nrename-command FLUSHALL \"\"\nrename-command CONFIG \"bgconfig get maxmemory\"<\/code><\/pre>\n<h3>4. ACL \u8bbf\u95ee\u63a7\u5236<\/h3>\n<pre><code># \u521b\u5efa\u7528\u6237\nACL SETUSER reader on ~cache:* +@read -@write\nACL SETUSER writer on ~cache:* +@read +@write\n\n# \u67e5\u770b\u7528\u6237\u5217\u8868\nACL LIST<\/code><\/pre>\n<h2>\u5341\u3001\u6700\u4f73\u5b9e\u8df5<\/h2>\n<h3>1. \u547d\u540d\u89c4\u8303<\/h3>\n<pre><code># \u683c\u5f0f\uff1a\u6a21\u5757\uff1a\u4e1a\u52a1\uff1a\u8d44\u6e90\nuser:1001:info\norder:1001:detail\ncart:user123:items<\/code><\/pre>\n<h3>2. \u952e\u503c\u8bbe\u8ba1<\/h3>\n<ul>\n<li>\u907f\u514d\u8fc7\u5927\u7684 key \u6216 value<\/li>\n<li>\u5408\u7406\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4<\/li>\n<li>\u4f7f\u7528 Hash \u5b58\u50a8\u5bf9\u8c61<\/li>\n<li>\u907f\u514d\u70ed key \u95ee\u9898<\/li>\n<\/ul>\n<h3>3. \u4e8b\u52a1\u548c pipeline<\/h3>\n<pre><code>\/\/ \u4f7f\u7528 pipeline \u6279\u91cf\u64cd\u4f5c\nPipeline pipeline = jedis.pipelined();\nfor (int i = 0; i < 1000; i++) {\n    pipeline.set(\"key:\" + i, \"value:\" + i);\n}\npipeline.sync();<\/code><\/pre>\n<h3>4. \u76d1\u63a7\u548c\u544a\u8b66<\/h3>\n<pre><code># \u76d1\u63a7\u6307\u6807\nMEMORY USED\nKEYS EXPIRED\nHITS MISS\nREJECTED_CONNECTIONS\nBLOCKED_KEYS<\/code><\/pre>\n<h2>\u5341\u4e00\u3001\u603b\u7ed3<\/h2>\n<p>Redis \u662f\u4e00\u4e2a\u9ad8\u6027\u80fd\u7684\u952e\u503c\u6570\u636e\u5e93\uff0c\u9002\u7528\u4e8e\u7f13\u5b58\u3001\u6d88\u606f\u961f\u5217\u3001\u8ba1\u6570\u5668\u7b49\u591a\u79cd\u573a\u666f\u3002\u901a\u8fc7\u5408\u7406\u7684\u914d\u7f6e\u548c\u4f18\u5316\uff0c\u53ef\u4ee5\u5145\u5206\u53d1\u6325 Redis \u7684\u6027\u80fd\u4f18\u52bf\uff0c\u6784\u5efa\u9ad8\u53ef\u7528\u3001\u9ad8\u6027\u80fd\u7684\u5e94\u7528\u7cfb\u7edf\u3002<\/p>\n<p>\u638c\u63e1 Redis \u7684\u6838\u5fc3\u6982\u5ff5\u3001\u914d\u7f6e\u65b9\u6cd5\u548c\u6700\u4f73\u5b9e\u8df5\uff0c\u80fd\u591f\u5e2e\u52a9\u5f00\u53d1\u8005\u89e3\u51b3\u5404\u79cd\u4e1a\u52a1\u6311\u6218\uff0c\u63d0\u5347\u7cfb\u7edf\u6027\u80fd\u3002<\/p>\n<div style=\"text-align:center;margin:30px 0;\">\n<p style=\"color:#666;font-size:14px;\">#Redis #\u6570\u636e\u5e93 #\u7f13\u5b58 #NoSQL #\u7f16\u7a0b\u6559\u7a0b<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Redis \u57fa\u7840\u914d\u7f6e\u4e0e\u4f7f\u7528\u5b8c\u5168\u6307\u5357 Redis \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u4f7f\u7528 ANSI C \u8bed\u8a00\u7f16\u5199\u3001\u652f\u6301\u7f51\u7edc\u3001\u53ef\u57fa\u4e8e\u5185\u5b58&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-15804","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.srclibs.com\/index.php\/wp-json\/wp\/v2\/posts\/15804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.srclibs.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.srclibs.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.srclibs.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.srclibs.com\/index.php\/wp-json\/wp\/v2\/comments?post=15804"}],"version-history":[{"count":0,"href":"https:\/\/www.srclibs.com\/index.php\/wp-json\/wp\/v2\/posts\/15804\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.srclibs.com\/index.php\/wp-json\/wp\/v2\/media?parent=15804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.srclibs.com\/index.php\/wp-json\/wp\/v2\/categories?post=15804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.srclibs.com\/index.php\/wp-json\/wp\/v2\/tags?post=15804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}