{"rsdb":{"rid":"395055","subhead":"","postdate":"0","aid":"272458","fid":"57","uid":"1","topic":"1","content":"

1.\u5206\u5e03\u5f0f\u9501:<\/p>

\u5b9e\u73b0\uff1a\u7528set key value ex time nx\u6307\u4ee4\u5b9e\u73b0\uff0c\u8fd9\u4e2a\u6307\u4ee4\u4ee5\u53ca\u5176\u53c2\u6570\u662f\u539f\u5b50\u6027\u7684\u64cd\u4f5c\u3002\u91ca\u653e\u9501\u7528del key\uff0c\u91ca\u653e\u4e4b\u524d\u5148\u6bd4\u8f83\u4e00\u4e0bvalue\u662f\u5426\u4e0e\u5f53\u524d\u7684value\u4e00\u6837\uff0c\u539f\u56e0\u89c1\u540e\u9762\u3002key\u4e3a\u9501\u540d\u3002value\u4e3a\u968f\u673a\u6570\u5e76\u7528\u4e00\u4e2a\u53d8\u91cf\u8bb0\u5f55\u8fd9\u4e2a\u968f\u673a\u6570\u3002ex\u662f\u4e2aset\u6307\u4ee4\u7684\u53c2\u6570\uff0c\u4ee3\u8868time\u79d2\u540e\u8be5key\u81ea\u52a8\u5220\u9664\u3002nx\u662fset\u6307\u4ee4\u7684\u53c2\u6570\uff0c\u4ee3\u8868\u6ca1\u6709\u8be5key\u65f6\u624d\u8bbe\u7f6e\u5b83\u7684\u503c\u3002<\/p>

\u8bf4\u660e\uff1a\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4\u662f\u9632\u6b62\u5360\u6709\u9501\u7684\u7ebf\u7a0b\u51fa\u73b0\u5f02\u5e38\uff0c\u5bfc\u81f4\u4e00\u76f4\u4e0d\u91ca\u653e\u9501\u3002value\u4f7f\u7528\u968f\u673a\u6570\u7684\u539f\u56e0\uff1a\u8d85\u65f6\u540e\uff0c\u65b0\u7684\u7ebf\u7a0b\u83b7\u53d6\u9501\u4e86\u5e76\u4e3akey\u8bbe\u7f6e\u4e86\u65b0\u7684\u968f\u673a\u6570\uff0c\u539f\u5148\u7684\u7ebf\u7a0b\u8fd8\u4e00\u76f4\u5728\u6267\u884c\u903b\u8f91\uff0c\u6700\u540e\u5e76\u6267\u884c\u4e86del\u6307\u4ee4\uff0c\u5982\u679c\u4f7f\u7528\u4e86\u968f\u673a\u6570\uff0c\u5728\u5220\u9664\u524d\u6bd4\u8f83\u4e86\uff0c\u5c31\u4e0d\u4f1a\u628akey\u7ed9\u5220\u4e86\u3002\u9632\u6b62\u4e86\u5176\u4ed6\u7ebf\u7a0b\u91ca\u653e\u4e86\u5f53\u524d\u7ebf\u7a0b\u7684\u9501\u3002<\/p>

2.\u6d88\u606f\u961f\u5217\uff1a<\/p>

\u8bf4\u660e\uff1a\u4f7f\u7528\u963b\u585e\u8bfb\u800c\u4e0d\u662f\u8f6e\u8be2\u662f\u4e3a\u4e86\u9632\u6b62\u961f\u5217\u7a7a\u4e86\uff0c\u505a\u5927\u91cf\u65e0\u7528\u7684\u7a7a\u8f6e\u8be2\u3002<\/p>

3.\u4f7f\u7528\u4f4d\u56fe\u5b58\u50a8bool\u7c7b\u578b\u6570\u636e\uff1a<\/p>

\u8bf4\u660e\uff1a\u4f4d\u56fe\u7684\u8be6\u7ec6\u6307\u4ee4\u53ef\u81ea\u884c\u641c\u7d22\u3002\u9996\u5148\u89e3\u91ca\u4e00\u4e0b\u4f4d\u56fe\uff0c\u4f4d\u5373bit\u7684\u4e2d\u6587\u540d\u79f0\uff0c\u4f4d\u56fe\u7684\u6700\u5c0f\u5b58\u50a8\u5355\u4f4d\u5c31\u662fbit\uff0c\u7ed3\u6784\u5c5e\u4e8e\u6570\u7ec4\uff0c\u901a\u8fc7\u7d22\u5f15\u8bbe\u7f6e\u6570\u636e\u3002\u4e00\u4e2abit\u5c31\u662f\u4e8c\u8fdb\u5236\u91cc\u9762\u76840\u62161\uff0c\u4e00\u4e2a\u5b57\u8282(byte)\u7b49\u4e8e8\u4e2abit\u3002\u4e00\u4e2a\u82f1\u6587\u5b57\u6bcd\u7b49\u4e8e\u4e00\u4e2abyte\u3002\u6c49\u5b57\u5c31\u4e0d\u4e00\u5b9a\uff0c\u4e0d\u540c\u7684\u7f16\u7801\u5360\u7528\u4e0d\u540c\u7684\u5b57\u8282\uff0c\u6709\u7684\u662f\u4e24\u4e2a\u5b57\u8282\u6709\u7684\u662f\u4e09\u4e2a\u5b57\u8282\u3002\u53ef\u4ee5\u7528setbit\u8bbe\u7f6e\u4f4d\uff0c\u6bd4\u5982setbit key 1 1\uff0c\u610f\u4e3a\u5728\u7b2c\u4e8c\u4e2a\u4f4d\u7f6e\u4e0a\u8bbe\u7f6e\u4e3a1\uff0c0\u7684\u8bdd\u4e0d\u7528\u8bbe\u7f6e\uff0c\u9ed8\u8ba4\u5c31\u662f0\u3002<\/p>

\u5b9e\u73b0\uff1aRedis\u63d0\u4f9b\u4e86bitcount\u548cbitpos\u6307\u4ee4\u6765\u7edf\u8ba1\u548c\u67e5\u627e\u4f4d\u56fe\u7c7b\u578b\u6570\u636e\uff0c\u540e\u9762\u53ef\u4ee5\u52a0start\u548cend\u53c2\u6570\u9009\u62e9\u8303\u56f4\u3002bool\u7c7b\u578b\u7684\u6570\u636e\u6b63\u597d\u53ea\u89810\u548c1\uff0c\u5728\u6709\u5927\u91cf\u7684\u8fd9\u79cdbool\u6570\u636e\u65f6\uff0c\u4f7f\u7528\u4f4d\u56fe\u53ef\u4ee5\u8282\u7ea6\u975e\u5e38\u5927\u7684\u7a7a\u95f4\u3002\u5e94\u7528\u573a\u666f\u5e94\u8be5\u7c7b\u4f3c\u4e8e\u767b\u5f55\u8bb0\u5f55\u3001\u7b7e\u5230\u8bb0\u5f55\u7b49\u8fd9\u79cd\u7eafbool\u7c7b\u578b\u6570\u636e\u3002\u4f8b\u5982\uff0c\u67d0\u4ebaA\u7b2c3\u5929\u65f6\u7b7e\u5230\u4e86\uff0c\u5c31\u6267\u884csetbit Akey 2 1\u3002\u4ee5\u6b64\u7c7b\u63a8\uff0c\u60f3\u7edf\u8ba1\u7b7e\u5230\u5929\u6570\u65f6\u5c31\u6267\u884cbitcount Akey\u3002\u8fd4\u56de\u7684\u662f1\u7684\u4e2a\u6570\uff0c\u4e5f\u5c31\u662f\u7b7e\u5230\u5929\u6570\u3002bitpos\u83b7\u53d6\u7684\u662f\u7b2c\u4e00\u6b21\u51fa\u73b01\u7684\u4f4d\u7f6e\uff0c\u5982bitpos Akey 1.\u8fd4\u56de\u7684\u662f\u7b2c\u4e00\u6b21\u51fa\u73b01\u7684\u4f4d\u7f6e\uff0c\u4e5f\u5c31\u662fA\u7b2c\u4e00\u5929\u7b7e\u5230\u662f\u4ec0\u4e48\u65f6\u5019\u3002<\/p>

4.HyperLogLog\u7edf\u8ba1UV\uff1a<\/p>

\u8bf4\u660e\uff1aHyperLogLog\u662fRedis\u7684\u9ad8\u7ea7\u6570\u636e\u7ed3\u6784\uff0c\u4f5c\u7528\u662f\u7edf\u8ba1\u57fa\u6570\uff0c\u6bd4\u5982\u5143\u7d20\u67091\uff0c2\uff0c3\uff0c4\uff0c5\uff0c5\uff0c6\u3002HyperLogLog\u53ea\u4f1a\u7edf\u8ba1\u57fa\u65706\uff0c\u53731\uff0c2\uff0c3\uff0c4\uff0c5\uff0c6\u4e0d\u91cd\u590d\u7684\u5143\u7d20\u7684\u4e2a\u6570\uff0c\u6700\u91cd\u8981\u7684\u662f\uff0c\u5373\u4f7f\u5143\u7d20\u975e\u5e38\u5927\uff0c\u5b83\u6240\u5360\u6709\u7684\u5185\u5b58\u4e5f\u662f\u56fa\u5b9a\u7684\uff0c\u6bcf\u4e2aHyperLogLog\u53ea\u9700\u82b1\u8d3912KB\u3002\u5b83\u7684\u6307\u4ee4\u5f88\u5c11\u3002\u4e3b\u8981\u6709\uff1apfadd key element\u6dfb\u52a0\u5143\u7d20\u3002pfcount key\u7edf\u8ba1\u57fa\u6570\u3002<\/p>

\u5b9e\u73b0\uff1a\u5728\u505aUV\u65f6\uff0c\u5373\u7edf\u8ba1\u72ec\u7acb\u8bbf\u5ba2\u6570\u5c31\u53ef\u4ee5\u7528\u4e0a\u4ed6\uff0c\u9488\u5bf9\u5168\u7f51\u7ad9\u3001\u5355\u72ec\u9875\u9762\u90fd\u53ef\u4ee5\u3002\u6211\u4eec\u53ea\u9700\u8981\u628aip\uff08\u6216\u7528\u6237id\uff09\u548c\u65e5\u671f\uff08\u7cbe\u786e\u5230\u5929\uff09\u6dfb\u52a0\u8fdb\u53bb\u5c31\u884c\u4e86\uff0c\u6709\u66f4\u591a\u5176\u4ed6\u4fe1\u606f\u4e5f\u884c\uff0c\u53cd\u6b63HyperLogLog\u53ea\u4f1a\u7edf\u8ba1\u57fa\u6570\u3002\u53ea\u8981\u4fdd\u8bc1\u5f53\u5929\u5185\u4e00\u4e2a\u7528\u6237\u7684\u4fe1\u606f\u7edd\u5bf9\u4e00\u6837\u5c31\u884c\u4e86\uff0c\u5b83\u4f1a\u81ea\u52a8\u53bb\u91cd\uff0c\u4e5f\u5c31\u662f\u4e00\u5929\u5185\u4e0d\u7ba1\u8fd9\u4e2a\u7528\u6237\u8bbf\u95ee\u591a\u5c11\u6b21\uff0c\u90fd\u53ea\u7b97\u4e00\u6b21\u3002<\/p>

5.\u7528scan\u641c\u7d22\u7279\u5b9a\u7684key\uff1a<\/p>

\u8bf4\u660e\uff1a\u5728\u6570\u636e\u91cf\u4e0d\u662f\u5f88\u5927\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u7528keys\u8fd9\u4e2a\u7b80\u5355\u7684\u6307\u4ee4\uff0c\u6309\u7167\u4e00\u5b9a\u7684\u89c4\u5219\u641c\u7d22\u5bf9\u5e94key\u3002\u4f46\u5f53\u6570\u636e\u91cf\u5927\u4e86\u4ee5\u540e\u663e\u7136\u5c31\u4e0d\u53ef\u53d6\u4e86\uff0c\u6700\u4e3b\u8981\u7684\u662fkeys\u662f\u963b\u585e\u7684\uff0c\u5b83\u4f1a\u53bb\u904d\u5386\u6240\u6709\u7684key\u76f4\u5230\u627e\u51fa\u7b26\u5408\u6761\u4ef6\u7684key\uff0c\u65f6\u95f4\u590d\u6742\u5ea6\u662fO(n)\u3002scan\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u867d\u7136\u4e5f\u662fO(n),\u4f46\u662f\u5b83\u4e0d\u4f1a\u963b\u585e\u7ebf\u7a0b\uff0c\u53ef\u4ee5\u9650\u5b9a\u8fd4\u56de\u7684\u4e2a\u6570\u3002scan\u662f\u4e00\u7cfb\u5217\u7684\u6307\u4ee4\uff0c\u9488\u5bf9\u4e0d\u540c\u7684\u57fa\u672c\u6570\u636e\u7c7b\u578b\u90fd\u6709\u5bf9\u5e94\u7684\u4e00\u4e9b\u6307\u4ee4\uff0c\u641c\u7d22key\u53ea\u662f\u6700\u57fa\u672c\u7684\u7528\u6cd5\uff0c\u66f4\u8be6\u7ec6\u7684\u7528\u6cd5\u53ef\u4ee5\u67e5\u627e\u5b98\u65b9api\u6587\u6863\u3002<\/p>

\u5b9e\u73b0\uff1a\u4f7f\u7528\u6307\u4ee4scan start match key* count limit\u3002start\u662f\u6e38\u6807\u5f00\u59cb\u7684\u5730\u65b9\uff0c\u6b63\u662f\u56e0\u4e3a\u4f7f\u7528\u7684\u662f\u6e38\u6807\uff0c\u6240\u4ee5\u4e0d\u4f1a\u9020\u6210\u7ebf\u7a0b\u963b\u585e\u3002match\u540e\u9762\u63a5\u6b63\u5219\u8868\u8fbe\u5f0f\u3002count\u540e\u9762\u63a5\u9650\u5b9a\u7684\u8fd4\u56de\u6570\u91cf\u3002\u6bd4\u5982\uff1ascan 0 match person* count 1000\uff0c\u6e38\u6807\u4ece0\u5f00\u59cb\uff0c\u8fd4\u56de\u6700\u591a1000\u6761person\u5f00\u5934\u7684key\u3002\u4f1a\u8fd4\u56de\u4e24\u4e2a\u7ed3\u679c\uff0c\u4e00\u4e2a\u662f\u6e38\u6807\u505c\u6b62\u7684\u5730\u65b9\uff0c\u662f\u4e2a\u6574\u6570\uff0c\u4e0b\u6b21\u5c31\u628a0\u6362\u6210\u8fd9\u4e2a\u6574\u6570\u63a5\u7740\u627e\u3002\u53e6\u4e00\u4e2a\u5c31\u662f\u627e\u5230\u7684key\u4e86\u3002<\/p>","orderid":"0","title":"Redis\u7684\u51e0\u79cd\u5e94\u7528\u5b9e\u6218","smalltitle":"","mid":"0","fname":"\u6570\u636e\u5e93\u7f16\u7a0b","special_id":"0","bak_id":"0","info":"0","hits":"345","pages":"1","comments":"0","posttime":"2023-07-26 08:18:13","list":"1690330693","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"Redis<\/A> \u5e94\u7528\u5b9e<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"119.59.235.169","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"Redis\u7684\u51e0\u79cd\u5e94\u7528\u5b9e\u6218","lastview":"1715139479","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}