{"id":10007024,"date":"2022-12-27T20:16:08","date_gmt":"2022-12-27T12:16:08","guid":{"rendered":"https:\/\/ityet.com\/?p=10007024"},"modified":"2022-12-27T20:16:08","modified_gmt":"2022-12-27T12:16:08","slug":"%e5%ad%a6%e4%b9%a0%e4%b8%8bredis%e5%86%85%e5%ad%98%e6%a8%a1%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10007024","title":{"rendered":"\u5b66\u4e60\u4e0bRedis\u5185\u5b58\u6a21\u578b"},"content":{"rendered":"<h5>\u4f5c\u8005\uff1a\u4eac\u4e1c\u96f6\u552e \u5434\u4f73<\/h5>\n<h2>\u524d\u8a00<\/h2>\n<p>redis\uff0c\u5bf9\u4e8e\u4e00\u4e2ajava\u5f00\u53d1\u5de5\u7a0b\u5e08\u6765\u8bb2\uff0c\u5176\u5b9e\u7b97\u4e0d\u5f97\u4ec0\u4e48\u590d\u6742\u65b0\u5947\u7684\u6280\u672f\uff0c\u4f46\u53ef\u80fd\u4e5f\u5f88\u5c11\u4eba\u53bb\u6df1\u5165\u4e86\u89e3\u5b66\u4e60\u5b83\u7684\u5e95\u5c42\u7684\u4e00\u4e9b\u4e1c\u897f\u3002\u4e0b\u9762\u5c06\u901a\u8fc7\u5bf9\u5185\u5b58\u7edf\u8ba1\u3001\u5185\u5b58\u5212\u5206\u3001\u5b58\u50a8\u7ec6\u8282\u3001\u5bf9\u8c61\u7c7b\u578b&#038;\u5185\u90e8\u7f16\u7801\u8fd9\u56db\u4e2a\u6a21\u5757\u6765\u5b66\u4e60\u5b66\u4e60redis\u7684\u5185\u5b58\u6a21\u578b\uff0c\u624b\u5b57\u7b14\u5f55\uff0c\u6f5c\u5fc3\u4fee\u884c\u3002<\/p>\n<h2>\u4e00\u3001redis\u7684\u5185\u5b58\u7edf\u8ba1<\/h2>\n<p>info memory \u547d\u4ee4\u67e5\u770b\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff1a\u670d\u52a1\u5668\u57fa\u672c\u4fe1\u606f\u3001CPU\u3001\u5185\u5b58\u3001\u6301\u4e45\u5316\u3001\u5ba2\u6237\u7aef\u8fde\u63a5\u4fe1\u606f\u7b49\u7b49\uff0c\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173878\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<h3><strong>\uff081\uff09used_memory\u548cused_memory_rss<\/strong><\/h3>\n<p>used_memory\uff1aRedis\u5206\u914d\u5668\u5206\u914d\u7684\u5185\u5b58\u603b\u91cf + \u865a\u62df\u5185\u5b58\uff08\u78c1\u76d8\uff09<\/p>\n<p>used_memory_rss\uff1aRedis\u8fdb\u7a0b\u5360\u636e\u64cd\u4f5c\u7cfb\u7edf\u7684\u5185\u5b58 + \u8fdb\u7a0b\u8fd0\u884c\u672c\u8eab\u9700\u8981\u7684\u5185\u5b58 + \u5185\u5b58\u788e\u7247\u7b49 \uff08*\uff1a\u6ce8\u610f used_memory_rss \u4e0d\u5305\u62ec\u865a\u62df\u5185\u5b58\uff09<\/p>\n<p>\u4e24\u8005\u533a\u522b\uff1a<\/p>\n<p>\u2460\u9762\u5411\u89d2\u5ea6\uff1aused_memory: Redis\u89d2\u5ea6 used_memory_rss\uff1a\u64cd\u4f5c\u7cfb\u7edf\u89d2\u5ea6<\/p>\n<p>\u2461\u5927\u5c0f\u4e0d\u4e00\u5b9a\u662f\u540e\u8005\u5927\u4e8e\u524d\u8005\uff1a\u5185\u5b58\u788e\u7247\u548cRedis\u8fdb\u7a0b\u8fd0\u884c\u9700\u8981\u5360\u7528\u5185\u5b58\uff0c\u4f7f\u5f97\u524d\u8005\u53ef\u80fd\u6bd4\u540e\u8005\u5c0f\uff0c\u53e6\u4e00\u65b9\u9762\u865a\u62df\u5185\u5b58\u7684\u5b58\u5728\uff0c\u4f7f\u5f97\u524d\u8005\u53ef\u80fd\u6bd4\u540e\u8005\u5927<\/p>\n<h3><strong>\uff082\uff09mem_fragmentation_ratio<\/strong><\/h3>\n<p>\u5185\u5b58\u788e\u7247\u6bd4\u7387\uff0c \u7b49\u4e8e used_memory_rss \/ used_memory<\/p>\n<p>mem_fragmentation_ratio &gt; 1 : \u503c\u8d8a\u5927\uff0c\u5185\u5b58\u788e\u7247\u6bd4\u4f8b\u8d8a\u5927<\/p>\n<p>mem_fragmentation_ratio &lt; 1 : \u8bf4\u660eRedis\u4f7f\u7528\u4e86\u865a\u62df\u5185\u5b58<\/p>\n<p>*:\u7531\u4e8e\u865a\u62df\u5185\u5b58\u7684\u5a92\u4ecb\u662f\u78c1\u76d8\uff0c\u6bd4\u5185\u5b58\u901f\u5ea6\u8981\u6162\u5f88\u591a\uff0c\u5f53\u8fd9\u79cd\u60c5\u51b5\u51fa\u73b0\u65f6\uff0c\u5e94\u8be5\u53ca\u65f6\u6392\u67e5\uff0c\u5982\u679c\u5185\u5b58\u4e0d\u8db3\u5e94\u8be5\u53ca\u65f6\u5904\u7406\uff0c\u5982\u589e\u52a0Redis\u8282\u70b9\u3001\u589e\u52a0Redis\u670d\u52a1\u5668\u7684\u5185\u5b58\u3001\u4f18\u5316\u5e94\u7528\u7b49\u3002<\/p>\n<p>\u6b63\u5e38\u60c5\u51b5\u4e0b\uff1amem_fragmentation_ratio = 1.03\u5de6\u53f3 \uff08\u5065\u5eb7\uff1a\u5bf9\u4e8ejemalloc\u6765\u8bf4\uff09<\/p>\n<p>\u4e0a\u9762\u7684\u60c5\u51b5\uff1a\u6ca1\u6709\u5411Redis\u4e2d\u5b58\u5165\u6570\u636e\uff0cRedis\u8fdb\u7a0b\u672c\u8eab\u8fd0\u884c\u7684\u5185\u5b58\u4f7f\u5f97used_memory_rss \u6bd4used_memory\u5927\u5f97\u591a<\/p>\n<h3><strong>\uff083\uff09mem_allocator\uff1a<\/strong><\/h3>\n<p>Redis\u4f7f\u7528\u7684\u5185\u5b58\u5206\u914d\u5668\uff0c\u5728\u7f16\u8bd1\u65f6\u6307\u5b9a\uff0c\u53ef\u4ee5\u662f libc \u3001jemalloc\u6216\u8005tcmalloc\uff0c\u9ed8\u8ba4\u662fjemalloc\u3002<\/p>\n<h3><strong>\uff084\uff09used_memory_peak\uff1a<\/strong><\/h3>\n<p>Redis\u7684\u5185\u5b58\u6d88\u8017\u5cf0\u503c<\/p>\n<h3><strong>\uff085\uff09used_memory_human\u548cused_memory_peak_human\uff1a<\/strong><\/h3>\n<p>\u5b57\u9762\u542b\u4e49\uff0c\u4ee5\u4eba\u7c7b\u9605\u8bfb\u7684\u65b9\u5f0f\u8fd4\u56de\u3002<\/p>\n<\/p>\n<h2>\u4e8c\u3001redis\u7684\u5185\u5b58\u5212\u5206<\/h2>\n<p>\u6570\u636e\uff1a\u6700\u4e3b\u8981\u7684\u90e8\u5206\uff0c\u4f1a\u7edf\u8ba1\u5728used_memory\u3002\u5b9e\u9645\u4e0a\uff0c\u5728Redis\u5185\u90e8\uff0c\u6bcf\u79cd\u7c7b\u578b\u53ef\u80fd\u67092\u79cd\u6216\u66f4\u591a\u7684\u5185\u90e8\u7f16\u7801\u5b9e\u73b0\u3002\u6b64\u5916\uff0cRedis\u5728\u5b58\u50a8\u5bf9\u8c61\u65f6\uff0c\u5e76\u4e0d\u662f\u76f4\u63a5\u5c06\u6570\u636e\u6254\u8fdb\u5185\u5b58\uff0c\u800c\u662f\u4f1a\u5bf9\u5bf9\u8c61\u8fdb\u884c\u5404\u79cd\u5305\u88c5\uff1a\u5982RedisObject\u3001SDS\u7b49\u3002<\/p>\n<p>\u8fdb\u7a0b\u672c\u8eab\u5185\u5b58\uff1aRedis\u4e3b\u8fdb\u7a0b\u672c\u8eab\u8fd0\u884c\u80af\u5b9a\u9700\u8981\u5360\u7528\u5185\u5b58\uff0c\u5982\u4ee3\u7801\u3001\u5e38\u91cf\u6c60\u7b49\u7b49\u3002\u8fd9\u90e8\u5206\u5185\u5b58\u5927\u7ea6\u51e0\u5146\uff0c\u5728\u5927\u591a\u6570\u751f\u4ea7\u73af\u5883\u4e2d\u4e0eRedis\u6570\u636e\u5360\u7528\u7684\u5185\u5b58\u76f8\u6bd4\u53ef\u4ee5\u5ffd\u7565\u3002\u8fd9\u90e8\u5206\u5185\u5b58\u4e0d\u662f\u7531jemalloc\u5206\u914d\uff0c\u56e0\u6b64\u4e0d\u4f1a\u7edf\u8ba1\u5728used_memory\u4e2d\u3002<\/p>\n<p>\u7f13\u51b2\u5185\u5b58\uff1a\u5305\u542b\u5ba2\u6237\u7aef\u7f13\u51b2\u533a\u3001\u590d\u5236\u79ef\u538b\u7f13\u51b2\u533a\u3001AOF\u7f13\u51b2\u533a<\/p>\n<p>\u5ba2\u6237\u7aef\u7f13\u51b2\u533a\uff1a\u5b58\u50a8\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u8f93\u5165\u8f93\u51fa\u7f13\u51b2<\/p>\n<p>\u590d\u5236\u79ef\u538b\u7f13\u51b2\u533a\uff1a\u7528\u4e8e\u90e8\u5206\u590d\u5236\u529f\u80fd<\/p>\n<p>AOF\u7f13\u51b2\u533a\uff1a\u7528\u4e8e\u5728\u8fdb\u884cAOF\u91cd\u5199\u65f6\uff0c\u4fdd\u5b58\u6700\u8fd1\u7684\u5199\u5165\u547d\u4ee4<\/p>\n<p>\u5185\u5b58\u788e\u7247\uff1a\u5185\u5b58\u788e\u7247\u662fRedis\u5728\u5206\u914d\u3001\u56de\u6536\u7269\u7406\u5185\u5b58\u8fc7\u7a0b\u4e2d\u4ea7\u751f\u7684\u3002<\/p>\n<\/p>\n<h2>\u4e09\u3001redis\u7684\u6570\u636e\u5b58\u50a8\u7ec6\u8282<\/h2>\n<p>\u5f53\u6211\u4eec\u6267\u884c\u4e00\u4e2aredis\u6307\u4ee4\uff0c\u6bd4\u5982\uff1aset hello world\uff0credis\u5e95\u5c42\u5b58\u50a8\u5230\u5e95\u5e72\u4e86\u4ec0\u4e48\uff1f<\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173879\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<h3>\u4e0a\u9762\u5c31\u6d89\u53ca\u5230\u4e24\u4e2a\u6982\u5ff5\uff1ajemalloc\u548cRedisObject<\/h3>\n<h3><strong>\uff081\uff09jemalloc<\/strong><\/h3>\n<p>\u5185\u5b58\u5206\u914d\u5668\uff1a\u53ef\u4ee5\u662f libc \u3001jemalloc\u6216\u8005tcmalloc\uff0c\u9ed8\u8ba4jemalloc<\/p>\n<p>jemalloc\u5185\u5b58\u5212\u5206\uff1a\u5c0f\u3001\u5927\u3001\u5de8\u5927\uff0c\u6bcf\u4e2a\u53c8\u5206\u8bb8\u591a\u5c0f\u5185\u5b58\u5757\u5355\u4f4d<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173880\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\uff08\u4f8b\u5982\uff0c\u5982\u679c\u9700\u8981\u5b58\u50a8\u5927\u5c0f\u4e3a130\u5b57\u8282\u7684\u5bf9\u8c61\uff0cjemalloc\u4f1a\u5c06\u5176\u653e\u5165160\u5b57\u8282\u7684\u5185\u5b58\u5355\u5143\u4e2d\u3002\uff09<\/p>\n<h3><strong>\uff082\uff09RedisObject\uff08\u6838\u5fc3\u6570\u636e\u7ed3\u6784\uff09<\/strong><\/h3>\n<p>redis\u7684\u4e94\u79cd\u7c7b\u578b\u90fd\u662f\u901a\u8fc7RedisObject\u5b58\u50a8\uff0cRedis\u5bf9\u8c61\u7684 \u7c7b\u578b\u3001\u5185\u90e8\u7f16\u7801\u3001\u5185\u5b58\u56de\u6536\u3001\u5171\u4eab\u5bf9\u8c61\u7b49\u529f\u80fd\u90fd\u9700\u8981RedisObject\u5bf9\u8c61\u652f\u6301\u3002<\/p>\n<pre><code>typedef struct redisObject{\n    unsigned type:4;\n    unsigned encoding:4;\n    unsigned lru:REDIS_LRU_BITS; \/* lru time (relative to server.lruclock) *\/       \n    int refcount;\n    void *ptr;\n}<\/code><\/pre>\n<p>type\uff1a\u8868\u793a\u5bf9\u8c61\u7684\u6570\u636e\u7c7b\u578b\uff0c\u53604bit\u3002<\/p>\n<p>encoding\uff1a\u8868\u793a\u5bf9\u8c61\u5185\u90e8\u7684\u7f16\u7801\uff0c\u53604bit\uff0c\u5bf9\u4e8eredis\u7684\u6bcf\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u90fd\u81f3\u5c11\u6709\u4fe9<\/p>\n<p>\u79cd\u5185\u90e8\u7f16\u7801\u3002\u6bd4\u5982\u5b57\u7b26\u4e32\u7c7b\u578b\u6709\uff1aint\u3001embstr\u3001raw\u3002<\/p>\n<p>lru\uff1a\u8bb0\u5f55\u7684\u662f\u5bf9\u8c61\u6700\u540e\u4e00\u6b21\u88ab\u547d\u4ee4\u7a0b\u5e8f\u8bbf\u95ee\u7684\u65f6\u95f4\uff0c\u5360\u636e\u7684\u6bd4\u7279\u6570\u4e0d\u540c\u7684\u7248\u672c\u6709\u6240\u4e0d\u540c\uff08\u59824.0\u7248\u672c\u536024\u6bd4\u7279\uff0c2.6\u7248\u672c\u536022\u6bd4\u7279\uff09\u3002<\/p>\n<p>refcount:<\/p>\n<p>1\u3001\u6982\u5ff5\uff1arefcount\u8bb0\u5f55\u7684\u662f\u8be5\u5bf9\u8c61\u88ab\u5f15\u7528\u7684\u6b21\u6570\uff0c\u7c7b\u578b\u76ee\u524d\u4ec5\u4e3a\u6574\u578b\u3002<\/p>\n<p>2\u3001\u4f5c\u7528\uff1arefcount\u7684\u4f5c\u7528\uff0c\u4e3b\u8981\u5728\u4e8e\u5bf9\u8c61\u7684\u5f15\u7528\u8ba1\u6570\u548c\u5185\u5b58\u56de\u6536\uff1a<\/p>\n<p>\u2460\u5f53\u521b\u5efa\u65b0\u5bf9\u8c61\u65f6\uff0crefcount\u521d\u59cb\u5316\u4e3a1\uff1b<\/p>\n<p>\u2461\u5f53\u6709\u65b0\u7a0b\u5e8f\u4f7f\u7528\u8be5\u5bf9\u8c61\u65f6\uff0crefcount\u52a01\uff1b<\/p>\n<p>\u2462\u5f53\u5bf9\u8c61\u4e0d\u518d\u88ab\u4e00\u4e2a\u65b0\u7a0b\u5e8f\u4f7f\u7528\u65f6\uff0crefcount\u51cf1\uff1b<\/p>\n<p>\u2463\u5f53refcount\u53d8\u4e3a0\u65f6\uff0c\u5bf9\u8c61\u5360\u7528\u7684\u5185\u5b58\u4f1a\u88ab\u91ca\u653e\u3002<\/p>\n<p>3\u3001\u4e3a\u4ec0\u4e48\u53ea\u652f\u6301\u6574\u6570\u503c\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\uff1f\u5bf9\u5185\u5b58\u548cCPU\uff08\u65f6\u95f4\uff09\u7684\u5e73\u8861\uff1a<\/p>\n<p>\u2460\u5bf9\u4e8e\u6574\u6570\u503c\uff0c\u5224\u65ad\u64cd\u4f5c\u590d\u6742\u5ea6\u4e3aO(1)\uff1b<\/p>\n<p>\u2461\u5bf9\u4e8e\u666e\u901a\u5b57\u7b26\u4e32\uff0c\u5224\u65ad\u590d\u6742\u5ea6\u4e3aO(n)\uff1b<\/p>\n<p>\u2462\u800c\u5bf9\u4e8e\u54c8\u5e0c\u3001\u5217\u8868\u3001\u96c6\u5408\u548c\u6709\u5e8f\u96c6\u5408\uff0c\u5224\u65ad\u7684\u590d\u6742\u5ea6\u4e3aO(n^2)\u3002<\/p>\n<p>4\u3001\u76ee\u524d\u5b9e\u73b0\uff1aRedis\u670d\u52a1\u5668\u5728\u521d\u59cb\u5316\u65f6\uff0c\u4f1a\u521b\u5efa10000\u4e2a\u5b57\u7b26\u4e32\u5bf9\u8c61\uff0c\u503c\u5206\u522b\u662f0~9999\u7684\u6574\u6570\u503c\uff1b10000\u8fd9\u4e2a\u6570\u5b57\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574\u53c2\u6570REDIS_SHARED_INTEGERS\uff084.0\u4e2d\u662f OBJ_SHARED_INTEGERS\uff09\u7684\u503c\u8fdb\u884c\u6539\u53d8\u3002\uff08\u5171\u4eab\u5bf9\u8c61\u7684\u5f15\u7528\u6b21\u6570\u53ef\u4ee5\u901a\u8fc7object refcount\u547d\u4ee4\u67e5\u770b\uff1a\uff09<\/p>\n<p>ptr:ptr\u6307\u9488\u6307\u5411\u5177\u4f53\u7684\u6570\u636e\uff0c\u5982\u524d\u9762\u7684\u4f8b\u5b50\u4e2d\uff0cset hello world\uff0cptr\u6307\u5411\u5305\u542b\u5b57\u7b26\u4e32world\u7684SDS<\/p>\n<h3><strong>\uff083\uff09SDS<\/strong><\/h3>\n<p>1\u3001\u6982\u5ff5\uff1aRedis\u6ca1\u6709\u76f4\u63a5\u4f7f\u7528C\u5b57\u7b26\u4e32(\u5373\u4ee5\u7a7a\u5b57\u7b26\u2018\/0\u2019\u7ed3\u5c3e\u7684\u5b57\u7b26\u6570\u7ec4)\u4f5c\u4e3a\u9ed8\u8ba4\u7684\u5b57\u7b26\u4e32\u8868\u793a\uff0c\u800c\u662f\u4f7f\u7528\u4e86SDS\u3002SDS\u662f\u7b80\u5355\u52a8\u6001\u5b57\u7b26\u4e32(Simple Dynamic String)\u7684\u7f29\u5199\u3002<\/p>\n<p>2\u3001\u7ed3\u6784\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173881\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p>3\u3001\u76f8\u5173\u8ba1\u7b97\uff1a<\/p>\n<p>*\uff1abuf\u6570\u7ec4\u7684\u957f\u5ea6 = free+len+1\uff08\u5176\u4e2d1\u8868\u793a\u5b57\u7b26\u4e32\u7ed3\u5c3e\u7684\u7a7a\u5b57\u7b26\uff09<\/p>\n<p>\u4e00\u4e2aSDS\u7ed3\u6784\u5360\u636e\u7684\u7a7a\u95f4 = free\u6240\u5360\u957f\u5ea6+len\u6240\u5360\u957f\u5ea6+ buf\u6570\u7ec4\u7684\u957f\u5ea6=4+4+free+len+1=free+len+9\u3002<\/p>\n<p>4\u3001\u52a0\u201c\/0\u201d\u76ee\u7684\uff1a\u4e3a\u4e86\u7b80\u5355\u5b57\u7b26\u4e32\u80fd\u591f\u8c03\u7528c\u5b57\u7b26\u4e32\u90e8\u5206\u51fd\u6570<\/p>\n<h2>\u56db\u3001redis\u7684\u5bf9\u8c61\u7c7b\u578b&#038;\u5185\u90e8\u7f16\u7801<\/h2>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173882\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<h3><strong>\uff081\uff09\u5b57\u7b26\u4e32<\/strong><\/h3>\n<p>1\u3001\u5b57\u7b26\u4e32\u957f\u5ea6\u4e0d\u8d85\u8fc7512MB<\/p>\n<p>2\u3001\u5185\u90e8\u7f16\u7801\u6709\u4e09\u79cd\uff1a int\u3001embstr\u3001raw<\/p>\n<p>3\u3001\u7f16\u7801\u8f6c\u6362\u5173\u7cfb\uff1a<\/p>\n<p>int\uff1a\u6574\u5f62<\/p>\n<p>embstr\uff1a&lt;=39\u5b57\u8282\u7684\u5b57\u7b26\u4e32<\/p>\n<p>raw\uff1a&gt;39\u5b57\u8282\u7684\u5b57\u7b26\u4e32<\/p>\n<p>4\u3001embstr\u548craw\u7684\u533a\u522b\uff1a<\/p>\n<p>\u2460embstr\u90fd\u4f7f\u7528redisObject\u548csds\u7ed3\u6784\u5b58\u50a8<\/p>\n<p>\u2461emstr\u521b\u5efa\u53ea\u5206\u914d\u4e00\u6b21\u5185\u5b58\u7a7a\u95f4\uff08redisObject\u548csds\u4e00\u8d77\u5206\u914d\uff0c\u56e0\u4e3a\u5b83\u662f\u8fde\u7eed\u7684\uff09<\/p>\n<p>\u7f3a\u70b9\uff1a\u521b\u5efa\u548c\u5220\u9664\u90fd\u9700\u8981\u6574\u4e2aredisObject\u548csds\u91cd\u65b0\u5206\u914d\u7a7a\u95f4\uff0c\u6240\u4ee5emstr\u5b9e\u73b0\u4e3a\u53ea\u8bfb\u3002<\/p>\n<p>\u2462raw\u9700\u8981\u5206\u914d\u4e24\u6b21<\/p>\n<p>5\u3001\u5f53emstr\u88ab\u4fee\u6539\u65f6\uff0c\u4f1a\u5148\u53d8\u6210raw\uff0c\u518d\u4fee\u6539\uff0c\u65e0\u8bba\u662f\u5426\u8fbe\u523039\u5b57\u8282<\/p>\n<p>\u8fd9\u4e5f\u662f\u4e3a\u4e86\u907f\u514d\u521b\u5efa\u6574\u4e2aredisObject\u548csds<\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173883\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173884\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<h3><strong>\uff082\uff09\u5217\u8868<\/strong><\/h3>\n<p>1\u3001\u5185\u90e8\u7f16\u7801\uff1aziplist\u548clinkedlist\uff1a\uff08\u6bcf\u4e2a\u8282\u70b9\u6307\u5411\u7684\u662fredisObject\uff09<\/p>\n<p>2\u3001\u538b\u7f29\u5217\u8868\uff1a\u8282\u7ea6\u7a7a\u95f4\uff0c\u8fde\u7eed\u5185\u5b58\u5757<\/p>\n<p>3\u3001\u7f16\u7801\u8f6c\u6362\uff1a\u4ec0\u4e48\u60c5\u51b5\u4e0b\u4f7f\u7528\u538b\u7f29\u5217\u8868\uff1f<\/p>\n<p>\u2460\u5217\u8868\u5143\u7d20 &lt; 512\u4e2a<\/p>\n<p>\u2461\u5217\u8868\u4e2d\u6240\u6709\u5b57\u7b26\u4e32\u5bf9\u8c61\u90fd\u4e0d\u8db364\u5b57\u8282\uff08\u5b57\u7b26\u4e32\u957f\u5ea6\uff09<\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173885\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173886\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<h3><strong>\uff083\uff09hash\uff1a<\/strong> <strong>\u5185\u5c42\u54c8\u5e0c\u548c\u5916\u5c42\u54c8\u5e0c<\/strong><\/h3>\n<p>\u5185\u5c42\u54c8\u5e0c\uff1aziplist\u3001hashtable<\/p>\n<p>\u5916\u5c42\u54c8\u5e0c\uff1ahashtable<\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173887\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000043173888\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000043173876\">https:\/\/segmentfault.com\/a\/1190000043173876<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u8005\uff1a\u4eac\u4e1c\u96f6\u552e \u5434\u4f73 \u524d\u8a00 redis\uff0c\u5bf9\u4e8e\u4e00\u4e2ajava\u5f00\u53d1\u5de5\u7a0b\u5e08\u6765\u8bb2\uff0c\u5176\u5b9e\u7b97\u4e0d\u5f97\u4ec0\u4e48\u590d\u6742\u65b0\u5947\u7684\u6280\u672f\uff0c\u4f46\u53ef\u80fd\u4e5f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10007024","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10007024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10007024"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10007024\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10007024"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10007024"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10007024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}