{"id":327,"date":"2012-07-16T20:59:10","date_gmt":"2012-07-16T12:59:10","guid":{"rendered":"http:\/\/www.royalwzy.com\/?p=327"},"modified":"2014-04-11T14:30:17","modified_gmt":"2014-04-11T06:30:17","slug":"redis%e5%ad%a6%e4%b9%a001-%e5%9c%a8linux%e4%b8%8b%e5%ae%89%e8%a3%85redis-v2-6-13","status":"publish","type":"post","link":"http:\/\/www.royalwzy.com\/?p=327","title":{"rendered":"Redis\u5b66\u4e6001&#8211;\u5728Linux\u4e0b\u5b89\u88c5Redis v2.6.13"},"content":{"rendered":"<div>\n<div>\u5b89\u88c5Redis<\/div>\n<div>\n<ol>\n<li>Redis\u7684\u4ecb\u7ecd:\n<ol>\n<li>redis\u662f\u4e00\u4e2a\u5f00\u6e90\u7684key-value\u6570\u636e\u5e93,\u5b83\u53c8\u7ecf\u5e38\u88ab\u8ba4\u4e3a\u662f\u4e00\u4e2a\u6570\u636e\u7ed3\u6784\u670d\u52a1\u5668,\u56e0\u4e3a\u5b83\u7684value\u4e0d\u4ec5\u5305\u62ec\u57fa\u672c\u7684string\u7c7b\u578b\u8fd8\u6709list,set,sorted set\u548chash\u7c7b\u578b,\u5f53\u7136\u8fd9\u4e9b\u7c7b\u578b\u7684\u5143\u7d20\u4e5f\u90fd\u662fstring\u7c7b\u578b,\u4e5f\u5c31\u662f\u8bf4list,set\u8fd9\u4e9b\u96c6\u5408\u7c7b\u578b\u4e5f\u53ea\u80fd\u5305\u542bstring\u7c7b\u578b;<\/li>\n<li>\u53ef\u4ee5\u5728\u8fd9\u4e9b\u7c7b\u578b\u4e0a\u505a\u5f88\u591a\u539f\u5b50\u6027\u7684\u64cd\u4f5c,\u6bd4\u5982\u5bf9\u4e00\u4e2a\u5b57\u7b26value\u8ffd\u52a0\u5b57\u7b26\u4e32(APPEND\u547d\u4ee4),\u52a0\u52a0\u6216\u8005\u51cf\u51cf\u4e00\u4e2a\u6570\u5b57\u5b57\u7b26\u4e32(INCR\u547d\u4ee4,\u5f53\u7136\u662f\u6309\u6574\u6570\u5904\u7406\u7684),\u53ef\u4ee5\u5bf9list\u7c7b\u578b\u8fdb\u884cpush,\u6216\u8005pop\u5143\u7d20\u64cd\u4f5c(\u53ef\u4ee5\u6a21\u62df\u6808\u548c\u961f\u5217),\u5bf9\u4e8eset\u7c7b\u578b\u53ef\u4ee5\u8fdb\u884c\u4e00\u4e9b\u96c6\u5408\u76f8\u5173\u64cd\u4f5c(intersection,union,difference);<\/li>\n<li>memcache\u4e5f\u6709\u7c7b\u4f3c\u4e0e++,&#8211;\u7684\u547d\u4ee4,\u4e0d\u8fc7memcache\u7684value\u53ea\u5305\u62ecstring\u7c7b\u578b,\u8fdc\u6ca1\u6709redis\u7684value\u7c7b\u578b\u4e30\u5bcc;<\/li>\n<li>\u548cmemcahe\u4e00\u6837\u4e3a\u4e86\u6027\u80fd,redis\u7684\u6570\u636e\u901a\u5e38\u90fd\u662f\u653e\u5230\u5185\u5b58\u4e2d\u7684,\u5f53\u7136redis\u53ef\u4ee5\u6bcf\u95f4\u9694\u4e00\u5b9a\u65f6\u95f4\u5c06\u5185\u5b58\u4e2d\u6570\u636e\u5199\u5165\u5230\u78c1\u76d8\u4ee5\u9632\u6b62\u6570\u636e\u4e22\u5931;<\/li>\n<li>redis\u4e5f\u652f\u6301\u4e3b\u4ece\u590d\u5236\u673a\u5236(master-slave replication),redis\u7684\u5176\u5b83\u7279\u6027\u5305\u62ec\u7b80\u5355\u7684\u4e8b\u52a1\u652f\u6301\u548c\u53d1\u5e03\u8ba2\u9605(pub\/sub)\u901a\u9053\u529f\u80fd,\u800c\u4e14redis\u914d\u7f6e\u7ba1\u7406\u975e\u5e38\u7b80\u5355,\u8fd8\u6709\u5404\u79cd\u8bed\u8a00\u7248\u672c\u7684\u5f00\u6e90\u5ba2\u6237\u7aef\u7c7b\u5e93;<\/li>\n<\/ol>\n<\/li>\n<li>key-list\u7c7b\u578b\u5185\u5b58\u6570\u636e\u5f15\u64ce:\n<ol>\n<li>\u4e92\u8054\u7f51\u6570\u636e\u76ee\u524d\u57fa\u672c\u4f7f\u7528\u4e24\u79cd\u65b9\u5f0f\u6765\u5b58\u50a8,\u5173\u7cfb\u6570\u636e\u5e93\u6216\u8005key value,\u4f46\u662f\u8fd9\u4e9b\u4e92\u8054\u7f51\u4e1a\u52a1\u672c\u8eab\u5e76\u4e0d\u5c5e\u4e8e\u8fd9\u4e24\u79cd\u6570\u636e\u7c7b\u578b,\u6bd4\u5982\u7528\u6237\u5728\u793e\u4f1a\u5316\u5e73\u53f0\u4e2d\u7684\u5173\u7cfb,\u5b83\u662f\u4e00\u4e2alist,\u5982\u679c\u8981\u7528\u5173\u7cfb\u6570\u636e\u5e93\u5b58\u50a8\u5c31\u9700\u8981\u8f6c\u6362\u6210\u4e00\u79cd\u591a\u884c\u8bb0\u5f55\u7684\u5f62\u5f0f,\u8fd9\u79cd\u5f62\u5f0f\u5b58\u5728\u5f88\u591a\u5197\u4f59\u6570\u636e,\u6bcf\u4e00\u884c\u9700\u8981\u5b58\u50a8\u4e00\u4e9b\u91cd\u590d\u4fe1\u606f;\u5982\u679c\u7528key value\u5b58\u50a8\u5219\u4fee\u6539\u548c\u5220\u9664\u6bd4\u8f83\u9ebb\u70e6,\u9700\u8981\u5c06\u5168\u90e8\u6570\u636e\u8bfb\u51fa\u518d\u5199\u5165; &#8212; by timyang@weibo.com<\/li>\n<li>\u5982\u679c\u7528key-value\u4e2d\u7684value\u5b58\u50a8list,\u53ea\u80fd\u5b9e\u73b0\u6700\u7b80\u5355\u7684\u5217\u8868\u529f\u80fd(\u6309\u7167id\u6216\u65f6\u95f4\u5148\u540e\u6392\u5e8f,\u4f8b\u5982\u4f7f\u7528memcache\u7684append\u6216prepend\u534f\u8bae),\u5176\u4ed6list\u64cd\u4f5c\u53ea\u80fd\u9760\u5ba2\u6237\u7aef\u64cd\u4f5c,\u6027\u80fd\u5f88\u5dee,\u5982\u679c\u6570\u636e\u91cf\u8f83\u5927,\u64cd\u4f5c\u65f6\u95f4\u662f\u65e0\u6cd5\u63a5\u53d7\u7684,\u5e76\u53d1\u4e5f\u4f1a\u9047\u5230\u5de8\u5927\u6311\u6218);<\/li>\n<li>key-list\u7cfb\u7edfkey\u5bf9\u5e94\u7684&#8221;value&#8221;\u662f\u4e00\u4e2alist(eg.set list),\u53ef\u4ee5\u5bf9list\u4e2d\u7684\u5355\u4e2aitem\u8fdb\u884c\u64cd\u4f5c,\u7406\u60f3\u7684key-list\u9700\u8981\u5982\u4e0b\u7279\u70b9:\n<ol>\n<li>list\u53ef\u4ee5\u662f\u6d77\u91cf\u7684,\u4e14\u64cd\u4f5c\u6027\u80fd\u9ad8\u6548;<\/li>\n<li>list\u662f\u53ef\u4ee5\u662f\u6709\u5e8f\u7684,\u4e14\u53ef\u52a8\u6001\u8c03\u6574\u987a\u5e8f;<\/li>\n<\/ol>\n<\/li>\n<li>\u4f7f\u7528\u573a\u666f:\n<ol>\n<li>\u8bba\u575b\u4e2d\u7684\u4e3b\u9898\u5217\u8868,\u56de\u590d\u5217\u8868;<\/li>\n<li>\u5fae\u535a\u4e2d\u7684\u7528\u6237\u5173\u6ce8\u5217\u8868,\u7528\u6237feed\u5217\u8868,\u7528\u6237\u5173\u6ce8feed\u5217\u8868;<\/li>\n<li>\u6700\u8fd1\u8bbf\u95ee\u5217\u8868;<\/li>\n<li>\u96c6\u5408\u64cd\u4f5c:\u6c42\u4ea4\u96c6,\u5e76\u96c6,\u5dee\u96c6(sdiff\/sinter\/sunion);<\/li>\n<li>\u597d\u53cb\u63a8\u8350;<\/li>\n<li>\u6392\u884c\u699c;<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<li>\u4e0b\u8f7d:\n<ol>\n<li>\u5b98\u65b9\u5730\u5740:\u00a0<a href=\"http:\/\/redis.io\/\">http:\/\/redis.io\/<\/a>;<\/li>\n<li>\u4e0b\u8f7d\u5730\u5740:\u00a0<a href=\"http:\/\/redis.io\/download\">http:\/\/redis.io\/download<\/a>;<\/li>\n<li>\u6587\u6863\u5730\u5740:\u00a0<a href=\"http:\/\/redis.io\/documentation\">http:\/\/redis.io\/documentation<\/a>;<\/li>\n<li>\u4f5c\u8005blog:\u00a0<a href=\"http:\/\/oldblog.antirez.com\/\">http:\/\/oldblog.antirez.com\/<\/a>;<\/li>\n<\/ol>\n<\/li>\n<li>\u5b89\u88c5:\n<ol>\n<li>\u89e3\u538b\u7f29\u5230\/usr\/local\u76ee\u5f55\u4e0b:tar -zxvf \/tools\/redis-2.6.13.tar.gz -C \/usr\/local\/; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(193).png\" width=\"895\" height=\"24\" \/><\/li>\n<li>\u7f16\u8bd1:cd \/usr\/local\/redis-2.6.13\/;make; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(194).png\" width=\"896\" height=\"41\" \/><\/li>\n<li>\u5b89\u88c5\u65f6\u62a5\u9519:undefined reference to `__sync_add_and_fetch_4&#8242;; \u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(195).png\" width=\"897\" height=\"92\" \/><\/li>\n<li>\u662f\u56e0\u4e3aCPU\u4fe1\u606f\u5224\u65ad\u5931\u8bef\u5f15\u8d77\u7684,\u6240\u4ee5\u9700\u8981\u786e\u5b9aCPU\u7684\u4fe1\u606f,\u7136\u540e\u628aCPU\u7684\u4fe1\u606f\u8bbe\u7f6e\u5230\u73af\u5883\u53d8\u91cf\u4e2d,\u6e05\u9664\u65e7\u7684\u7f16\u8bd1\u6587\u4ef6,\u6700\u540e\u91cd\u65b0\u7f16\u8bd1\u5373\u53ef:uname -a(uname -m);export CFLAGS=-march=i686;cd \/usr\/local\/redis-2.6.13\/;make distclean;make; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(196).png\" width=\"896\" height=\"381\" \/><\/li>\n<li>\u5982\u679c\u9700\u8981\u8fd0\u884cmake-test\u7684\u8bdd\u9700\u8981\u5b89\u88c58.5\u7248\u672c\u4ee5\u4e0a\u7684tcl;<\/li>\n<li>\u6b64\u65f6\u5c31\u4f1a\u5728src\u76ee\u5f55\u4e0b\u51fa\u73b0redis-server\u7684\u670d\u52a1\u7aef\u548credis-cli\u5ba2\u6237\u7aef,\u4e3a\u4e86\u65b9\u4fbf\u4f7f\u7528\u53ef\u4ee5\u5206\u522b\u521b\u5efa\u8f6f\u8fde\u63a5:ln -s \/usr\/local\/redis-2.6.13\/src\/redis-server \/usr\/local\/redis-2.6.13\/src\/redisd;ln -s \/usr\/local\/redis-2.6.13\/src\/redis-cli \/usr\/local\/redis-2.6.13\/src\/redis; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(197).png\" width=\"925\" height=\"43\" \/><\/li>\n<li>\u6dfb\u52a0PATH\u53d8\u91cf:PATH=$PATH:\/usr\/local\/redis-2.6.13\/src; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(198).png\" width=\"897\" height=\"27\" \/><\/li>\n<li>\u542f\u52a8\u670d\u52a1\u7aef:\n<ol>\n<li>\u9ed8\u8ba4\u914d\u7f6e\u542f\u52a8:redisd;<\/li>\n<li>\u4f7f\u7528\u81ea\u5df1\u7684\u914d\u7f6e\u6587\u4ef6\u542f\u52a8:redisd \/etc\/redis.conf;<\/li>\n<li>\u5728\u540e\u53f0\u8fd0\u884c:redisd \/etc\/redis.conf &amp;; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(199).png\" width=\"894\" height=\"56\" \/><\/li>\n<\/ol>\n<\/li>\n<li>\u542f\u52a8\u5ba2\u6237\u7aef:redis; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(200).png\" width=\"894\" height=\"49\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"file:\/\/\/C:\/TEMP\/enhtmlclip\/Image(201).png\" width=\"897\" height=\"80\" \/><\/li>\n<\/ol>\n<\/li>\n<li>\u9a71\u52a8\u4e0b\u8f7d:\n<ol>\n<li>\u5b98\u7f51\u63d0\u4f9b\u7684\u652f\u6301\u8bed\u8a00\u7684\u4e0b\u8f7d\u5730\u5740:\u00a0<a href=\"http:\/\/redis.io\/clients\">http:\/\/redis.io\/clients<\/a>;<\/li>\n<li>Jedis\u7684github\u5730\u5740:<a href=\"https:\/\/github.com\/xetorthio\/jedis\">https:\/\/github.com\/xetorthio\/jedis<\/a>;<\/li>\n<li>jar\u5305\u4e0b\u8f7d\u5730\u5740:<a href=\"https:\/\/github.com\/xetorthio\/jedis\/downloads\">https:\/\/github.com\/xetorthio\/jedis\/downloads<\/a>;<\/li>\n<li>\u63d0\u4f9b\u7684\u65b9\u6cd5:\n<ol>\n<li>Sorting<\/li>\n<li>Connection handling<\/li>\n<li>Commands operating on any kind of values<\/li>\n<li>Commands operating on string values<\/li>\n<li>Commands operating on hashes<\/li>\n<li>Commands operating on lists<\/li>\n<li>Commands operating on sets<\/li>\n<li>Commands operating on sorted sets<\/li>\n<li>Transactions<\/li>\n<li>Pipelining<\/li>\n<li>Publish\/Subscribe<\/li>\n<li>Persistence control commands<\/li>\n<li>Remote server control commands<\/li>\n<li>Connection pooling<\/li>\n<li>Sharding (MD5, MurmureHash)<\/li>\n<li>Key-tags for sharding<\/li>\n<li>Sharding with pipelining<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<li>\u914d\u7f6e\u6587\u4ef6;<\/li>\n<\/ol>\n<\/div>\n<div>\n<div align=\"left\"><span style=\"color: #010101;\"># Redis configuration file example<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Note on units: when memory size is needed, it is possible to specify<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># it in the usual form of 1k 5GB 4M and so forth:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 1k =&gt; 1000 bytes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 1kb =&gt; 1024 bytes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 1m =&gt; 1000000 bytes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 1mb =&gt; 1024*1024 bytes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 1g =&gt; 1000000000 bytes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 1gb =&gt; 1024*1024*1024 bytes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># units are case insensitive so 1GB 1Gb 1gB are all the same.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># By default Redis does not run as a daemon. Use &#8216;yes&#8217; if you need it.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Note that Redis will write a pid file in \/var\/run\/redis.pid when daemonized.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #e30000;\">daemonize yes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># When running daemonized, Redis writes a pid file in \/var\/run\/redis.pid by<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># default. You can specify a custom pid file location here.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">pidfile \/var\/run\/redis.pid<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Accept connections on the specified port, default is 6379.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If port 0 is specified Redis will not listen on a TCP socket.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #e30000;\">port 6379<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If you want you can bind a single interface, if the bind option is not<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># specified all the interfaces will listen for incoming connections.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># bind 127.0.0.1<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Specify the path for the unix socket that will be used to listen for<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># incoming connections. There is no default, so Redis will not listen<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># on a unix socket when not specified.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># unixsocket \/tmp\/redis.sock<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># unixsocketperm 755<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Close the connection after a client is idle for N seconds (0 to disable)<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">timeout 0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># TCP keepalive.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># of communication. This is useful for two reasons:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 1) Detect dead peers.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 2) Take the connection alive from the point of view of network<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0 equipment in the middle.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># On Linux, the specified value (in seconds) is the period used to send ACKs.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Note that to close the connection the double of the time is needed.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># On other kernels the period depends on the kernel configuration.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># A reasonable value for this option is 60 seconds.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">tcp-keepalive 0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Specify the server verbosity level.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># This can be one of:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># debug (a lot of information, useful for development\/testing)<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># verbose (many rarely useful info, but not a mess like the debug level)<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># notice (moderately verbose, what you want in production probably)<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># warning (only very important \/ critical messages are logged)<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">loglevel notice<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Specify the log file name. Also &#8216;stdout&#8217; can be used to force<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Redis to log on the standard output. Note that if you use standard<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># output for logging but daemonize, logs will be sent to \/dev\/null<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">logfile stdout<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># To enable logging to the system logger, just set &#8216;syslog-enabled&#8217; to yes,<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># and optionally update the other syslog parameters to suit your needs.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># syslog-enabled no<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Specify the syslog identity.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># syslog-ident redis<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># syslog-facility local0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Set the number of databases. The default database is DB 0, you can select<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># a different one on a per-connection basis using SELECT &lt;dbid&gt; where<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># dbid is a number between 0 and &#8216;databases&#8217;-1<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">databases 16<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">################################ SNAPSHOTTING\u00a0 #################################<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Save the DB on disk:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 save &lt;seconds&gt; &lt;changes&gt;<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 Will save the DB if both the given number of seconds and the given<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 number of write operations against the DB occurred.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 In the example below the behaviour will be to save:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 after 900 sec (15 min) if at least 1 key changed<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 after 300 sec (5 min) if at least 10 keys changed<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 after 60 sec if at least 10000 keys changed<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 Note: you can disable saving at all commenting all the &#8220;save&#8221; lines.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 It is also possible to remove all the previously configured save<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 points by adding a save directive with a single empty string argument<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 like in the following example:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0 save &#8220;&#8221;<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #e30000;\">#save 900 1<\/span><\/div>\n<div align=\"left\"><span style=\"color: #e30000;\">#save 300 10<\/span><\/div>\n<div align=\"left\"><span style=\"color: #e30000;\">#save 60 10000<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># By default Redis will stop accepting writes if RDB snapshots are enabled<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># (at least one save point) and the latest background save failed.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># This will make the user aware (in an hard way) that data is not persisting<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># on disk properly, otherwise chances are that no one will notice and some<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># distater will happen.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If the background saving process will start working again Redis will<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># automatically allow writes again.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># However if you have setup your proper monitoring of the Redis server<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># and persistence, you may want to disable this feature so that Redis will<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># continue to work as usually even if there are problems with disk,<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># permissions, and so forth.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">stop-writes-on-bgsave-error yes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Compress string objects using LZF when dump .rdb databases?<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># For default that&#8217;s set to &#8216;yes&#8217; as it&#8217;s almost always a win.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If you want to save some CPU in the saving child set it to &#8216;no&#8217; but<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># the dataset will likely be bigger if you have compressible values or keys.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">rdbcompression yes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Since version 5 of RDB a CRC64 checksum is placed at the end of the file.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># This makes the format more resistant to corruption but there is a performance<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># hit to pay (around 10%) when saving and loading RDB files, so you can disable it<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># for maximum performances.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># RDB files created with checksum disabled have a checksum of zero that will<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># tell the loading code to skip the check.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">rdbchecksum yes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The filename where to dump the DB<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">dbfilename dump.rdb<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The working directory.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The DB will be written inside this directory, with the filename specified<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># above using the &#8216;dbfilename&#8217; configuration directive.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The Append Only File will also be created inside this directory.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Note that you must specify a directory here, not a file name.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">dir .\/<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">################################# REPLICATION #################################<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Master-Slave replication. Use slaveof to make a Redis instance a copy of<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># another Redis server. Note that the configuration is local to the slave<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># so for example it is possible to configure the slave to save the DB with a<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># different interval, or to listen to another port, and so on.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># slaveof &lt;masterip&gt; &lt;masterport&gt;<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If the master is password protected (using the &#8220;requirepass&#8221; configuration<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># directive below) it is possible to tell the slave to authenticate before<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># starting the replication synchronization process, otherwise the master will<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># refuse the slave request.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># masterauth &lt;master-password&gt;<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># When a slave loses its connection with the master, or when the replication<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># is still in progress, the slave can act in two different ways:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 1) if slave-serve-stale-data is set to &#8216;yes&#8217; (the default) the slave will<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0 still reply to client requests, possibly with out of date data, or the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0 data set may just be empty if this is the first synchronization.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 2) if slave-serve-stale-data is set to &#8216;no&#8217; the slave will reply with<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0 an error &#8220;SYNC with master in progress&#8221; to all the kind of commands<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0 but to INFO and SLAVEOF.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">slave-serve-stale-data yes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># You can configure a slave instance to accept writes or not. Writing against<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># a slave instance may be useful to store some ephemeral data (because data<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># written on a slave will be easily deleted after resync with the master) but<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># may also cause problems if clients are writing to it because of a<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># misconfiguration.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Since Redis 2.6 by default slaves are read-only.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Note: read only slaves are not designed to be exposed to untrusted clients<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># on the internet. It&#8217;s just a protection layer against misuse of the instance.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Still a read only slave exports by default all the administrative commands<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># such as CONFIG, DEBUG, and so forth. To a limited extend you can improve<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># security of read only slaves using &#8216;rename-command&#8217; to shadow all the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># administrative \/ dangerous commands.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">slave-read-only yes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Slaves send PINGs to server in a predefined interval. It&#8217;s possible to change<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># this interval with the repl_ping_slave_period option. The default value is 10<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># seconds.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># repl-ping-slave-period 10<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The following option sets a timeout for both Bulk transfer I\/O timeout and<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># master data or ping response timeout. The default value is 60 seconds.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># It is important to make sure that this value is greater than the value<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># specified for repl-ping-slave-period otherwise a timeout will be detected<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># every time there is low traffic between the master and the slave.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># repl-timeout 60<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Disable TCP_NODELAY on the slave socket after SYNC?<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If you select &#8220;yes&#8221; Redis will use a smaller number of TCP packets and<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># less bandwidth to send data to slaves. But this can add a delay for<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># the data to appear on the slave side, up to 40 milliseconds with<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Linux kernels using a default configuration.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If you select &#8220;no&#8221; the delay for data to appear on the slave side will<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># be reduced but more bandwidth will be used for replication.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># By default we optimize for low latency, but in very high traffic conditions<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># or when the master and slaves are many hops away, turning this to &#8220;yes&#8221; may<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># be a good idea.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">repl-disable-tcp-nodelay no<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The slave priority is an integer number published by Redis in the INFO output.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># It is used by Redis Sentinel in order to select a slave to promote into a<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># master if the master is no longer working correctly.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># A slave with a low priority number is considered better for promotion, so<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># for instance if there are three slaves with priority 10, 100, 25 Sentinel will<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># pick the one wtih priority 10, that is the lowest.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># However a special priority of 0 marks the slave as not able to perform the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># role of master, so a slave with priority of 0 will never be selected by<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Redis Sentinel for promotion.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># By default the priority is 100.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">slave-priority 100<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">################################## SECURITY ###################################<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Require clients to issue AUTH &lt;PASSWORD&gt; before processing any other<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># commands.\u00a0 This might be useful in environments in which you do not trust<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># others with access to the host running redis-server.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># This should stay commented out for backward compatibility and because most<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># people do not need auth (e.g. they run their own servers).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Warning: since Redis is pretty fast an outside user can try up to<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 150k passwords per second against a good box. This means that you should<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># use a very strong password otherwise it will be very easy to break.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># requirepass foobared<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Command renaming.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># It is possible to change the name of dangerous commands in a shared<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># environment. For instance the CONFIG command may be renamed into something<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># hard to guess so that it will still be available for internal-use tools<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># but not available for general clients.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Example:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># It is also possible to completely kill a command by renaming it into<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># an empty string:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># rename-command CONFIG &#8220;&#8221;<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Please note that changing the name of commands that are logged into the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># AOF file or transmitted to slaves may cause problems.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">################################### LIMITS ####################################<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Set the max number of connected clients at the same time. By default<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># this limit is set to 10000 clients, however if the Redis server is not<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># able to configure the process file limit to allow for the specified limit<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># the max number of allowed clients is set to the current file limit<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># minus 32 (as Redis reserves a few file descriptors for internal uses).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Once the limit is reached Redis will close all the new connections sending<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># an error &#8216;max number of clients reached&#8217;.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># maxclients 10000<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Don&#8217;t use more memory than the specified amount of bytes.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># When the memory limit is reached Redis will try to remove keys<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># accordingly to the eviction policy selected (see maxmemmory-policy).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If Redis can&#8217;t remove keys according to the policy, or if the policy is<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># set to &#8216;noeviction&#8217;, Redis will start to reply with errors to commands<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># that would use more memory, like SET, LPUSH, and so on, and will continue<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># to reply to read-only commands like GET.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># This option is usually useful when using Redis as an LRU cache, or to set<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># an hard memory limit for an instance (using the &#8216;noeviction&#8217; policy).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># WARNING: If you have slaves attached to an instance with maxmemory on,<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># the size of the output buffers needed to feed the slaves are subtracted<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># from the used memory count, so that network problems \/ resyncs will<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># not trigger a loop where keys are evicted, and in turn the output<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># buffer of slaves is full with DELs of keys evicted triggering the deletion<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># of more keys, and so forth until the database is completely emptied.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># In short&#8230; if you have slaves attached it is suggested that you set a lower<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># limit for maxmemory so that there is some free RAM on the system for slave<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># output buffers (but this is not needed if the policy is &#8216;noeviction&#8217;).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># maxmemory &lt;bytes&gt;<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># MAXMEMORY POLICY: how Redis will select what to remove when maxmemory<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># is reached. You can select among five behaviors:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># volatile-lru -&gt; remove the key with an expire set using an LRU algorithm<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># allkeys-lru -&gt; remove any key accordingly to the LRU algorithm<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># volatile-random -&gt; remove a random key with an expire set<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># allkeys-random -&gt; remove a random key, any key<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># volatile-ttl -&gt; remove the key with the nearest expire time (minor TTL)<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># noeviction -&gt; don&#8217;t expire at all, just return an error on write operations<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Note: with any of the above policies, Redis will return an error on write<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 operations, when there are not suitable keys for eviction.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 At the date of writing this commands are: set setnx setex append<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 getset mset msetnx exec sort<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The default is:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># maxmemory-policy volatile-lru<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># LRU and minimal TTL algorithms are not precise algorithms but approximated<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># algorithms (in order to save memory), so you can select as well the sample<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># size to check. For instance for default Redis will check three keys and<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># pick the one that was used less recently, you can change the sample size<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># using the following configuration directive.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># maxmemory-samples 3<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">############################## APPEND ONLY MODE ###############################<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># By default Redis asynchronously dumps the dataset on disk. This mode is<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># good enough in many applications, but an issue with the Redis process or<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># a power outage may result into a few minutes of writes lost (depending on<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># the configured save points).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The Append Only File is an alternative persistence mode that provides<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># much better durability. For instance using the default data fsync policy<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># (see later in the config file) Redis can lose just one second of writes in a<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># dramatic event like a server power outage, or a single write if something<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># wrong with the Redis process itself happens, but the operating system is<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># still running correctly.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># AOF and RDB persistence can be enabled at the same time without problems.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If the AOF is enabled on startup Redis will load the AOF, that is the file<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># with the better durability guarantees.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Please check http:\/\/redis.io\/topics\/persistence for more information.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #e30000;\">appendonly yes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The name of the append only file (default: &#8220;appendonly.aof&#8221;)<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># appendfilename appendonly.aof<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The fsync() call tells the Operating System to actually write data on disk<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># instead to wait for more data in the output buffer. Some OS will really flush<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># data on disk, some other OS will just try to do it ASAP.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Redis supports three different modes:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># no: don&#8217;t fsync, just let the OS flush the data when it wants. Faster.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># always: fsync after every write to the append only log . Slow, Safest.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># everysec: fsync only one time every second. Compromise.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The default is &#8220;everysec&#8221;, as that&#8217;s usually the right compromise between<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># speed and data safety. It&#8217;s up to you to understand if you can relax this to<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># &#8220;no&#8221; that will let the operating system flush the output buffer when<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># it wants, for better performances (but if you can live with the idea of<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># some data loss consider the default persistence mode that&#8217;s snapshotting),<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># or on the contrary, use &#8220;always&#8221; that&#8217;s very slow but a bit safer than<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># everysec.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># More details please check the following article:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># http:\/\/antirez.com\/post\/redis-persistence-demystified.html<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If unsure, use &#8220;everysec&#8221;.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #e30000;\"># appendfsync always<\/span><\/div>\n<div align=\"left\"><span style=\"color: #e30000;\">appendfsync everysec<\/span><\/div>\n<div align=\"left\"><span style=\"color: #e30000;\"># appendfsync no<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># When the AOF fsync policy is set to always or everysec, and a background<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># saving process (a background save or AOF log background rewriting) is<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># performing a lot of I\/O against the disk, in some Linux configurations<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Redis may block too long on the fsync() call. Note that there is no fix for<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># this currently, as even performing fsync in a different thread will block<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># our synchronous write(2) call.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># In order to mitigate this problem it&#8217;s possible to use the following option<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># that will prevent fsync() from being called in the main process while a<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># BGSAVE or BGREWRITEAOF is in progress.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># This means that while another child is saving, the durability of Redis is<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># the same as &#8220;appendfsync none&#8221;. In practical terms, this means that it is<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># possible to lose up to 30 seconds of log in the worst scenario (with the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># default Linux settings).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If you have latency problems turn this to &#8220;yes&#8221;. Otherwise leave it as<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># &#8220;no&#8221; that is the safest pick from the point of view of durability.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">no-appendfsync-on-rewrite no<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Automatic rewrite of the append only file.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Redis is able to automatically rewrite the log file implicitly calling<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># BGREWRITEAOF when the AOF log size grows by the specified percentage.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># This is how it works: Redis remembers the size of the AOF file after the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># latest rewrite (if no rewrite has happened since the restart, the size of<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># the AOF at startup is used).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># This base size is compared to the current size. If the current size is<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># bigger than the specified percentage, the rewrite is triggered. Also<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># you need to specify a minimal size for the AOF file to be rewritten, this<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># is useful to avoid rewriting the AOF file even if the percentage increase<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># is reached but it is still pretty small.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Specify a percentage of zero in order to disable the automatic AOF<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># rewrite feature.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">auto-aof-rewrite-percentage 100<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">auto-aof-rewrite-min-size 64mb<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">################################ LUA SCRIPTING\u00a0 ###############################<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Max execution time of a Lua script in milliseconds.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If the maximum execution time is reached Redis will log that a script is<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># still in execution after the maximum allowed time and will start to<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># reply to queries with an error.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># When a long running script exceed the maximum execution time only the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># used to stop a script that did not yet called write commands. The second<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># is the only way to shut down the server in the case a write commands was<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># already issue by the script but the user don&#8217;t want to wait for the natural<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># termination of the script.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Set it to 0 or a negative value for unlimited execution without warnings.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">lua-time-limit 5000<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">################################## SLOW LOG ###################################<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The Redis Slow Log is a system to log queries that exceeded a specified<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># execution time. The execution time does not include the I\/O operations<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># like talking with the client, sending the reply and so forth,<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># but just the time needed to actually execute the command (this is the only<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># stage of command execution where the thread is blocked and can not serve<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># other requests in the meantime).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># You can configure the slow log with two parameters: one tells Redis<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># what is the execution time, in microseconds, to exceed in order for the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># command to get logged, and the other parameter is the length of the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># slow log. When a new command is logged the oldest one is removed from the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># queue of logged commands.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The following time is expressed in microseconds, so 1000000 is equivalent<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># to one second. Note that a negative number disables the slow log, while<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># a value of zero forces the logging of every command.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">slowlog-log-slower-than 10000<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># There is no limit to this length. Just be aware that it will consume memory.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># You can reclaim memory used by the slow log with SLOWLOG RESET.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">slowlog-max-len 128<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">############################### ADVANCED CONFIG ###############################<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Hashes are encoded using a memory efficient data structure when they have a<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># small number of entries, and the biggest entry does not exceed a given<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># threshold. These thresholds can be configured using the following directives.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">hash-max-ziplist-entries 512<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">hash-max-ziplist-value 64<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Similarly to hashes, small lists are also encoded in a special way in order<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># to save a lot of space. The special representation is only used when<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># you are under the following limits:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">list-max-ziplist-entries 512<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">list-max-ziplist-value 64<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Sets have a special encoding in just one case: when a set is composed<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># of just strings that happens to be integers in radix 10 in the range<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># of 64 bit signed integers.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The following configuration setting sets the limit in the size of the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># set in order to use this special memory saving encoding.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">set-max-intset-entries 512<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Similarly to hashes and lists, sorted sets are also specially encoded in<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># order to save a lot of space. This encoding is only used when the length and<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># elements of a sorted set are below the following limits:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">zset-max-ziplist-entries 128<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">zset-max-ziplist-value 64<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># order to help rehashing the main Redis hash table (the one mapping top-level<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># keys to values). The hash table implementation Redis uses (see dict.c)<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># performs a lazy rehashing: the more operation you run into an hash table<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># that is rehashing, the more rehashing &#8220;steps&#8221; are performed, so if the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># server is idle the rehashing is never complete and some more memory is used<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># by the hash table.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The default is to use this millisecond 10 times every second in order to<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># active rehashing the main dictionaries, freeing memory when possible.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># If unsure:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># use &#8220;activerehashing no&#8221; if you have hard latency requirements and it is<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># not a good thing in your environment that Redis can reply form time to time<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># to queries with 2 milliseconds delay.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># use &#8220;activerehashing yes&#8221; if you don&#8217;t have such hard requirements but<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># want to free memory asap when possible.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">activerehashing yes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The client output buffer limits can be used to force disconnection of clients<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># that are not reading data from the server fast enough for some reason (a<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># common reason is that a Pub\/Sub client can&#8217;t consume messages as fast as the<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># publisher can produce them).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The limit can be set differently for the three different classes of clients:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># normal -&gt; normal clients<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># slave\u00a0 -&gt; slave clients and MONITOR clients<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># pubsub -&gt; clients subcribed to at least one pubsub channel or pattern<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The syntax of every client-output-buffer-limit directive is the following:<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># client-output-buffer-limit &lt;class&gt; &lt;hard limit&gt; &lt;soft limit&gt; &lt;soft seconds&gt;<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># A client is immediately disconnected once the hard limit is reached, or if<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># the soft limit is reached and remains reached for the specified number of<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># seconds (continuously).<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># So for instance if the hard limit is 32 megabytes and the soft limit is<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 16 megabytes \/ 10 seconds, the client will get disconnected immediately<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># if the size of the output buffers reach 32 megabytes, but will also get<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># disconnected if the client reaches 16 megabytes and continuously overcomes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># the limit for 10 seconds.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># By default normal clients are not limited because they don&#8217;t receive data<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># without asking (in a push way), but just after a request, so only<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># asynchronous clients may create a scenario where data is requested faster<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># than it can read.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Instead there is a default limit for pubsub and slave clients, since<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># subscribers and slaves receive data in a push fashion.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Both the hard or the soft limit can be disabled by setting them to zero.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">client-output-buffer-limit normal 0 0 0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">client-output-buffer-limit slave 256mb 64mb 60<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">client-output-buffer-limit pubsub 32mb 8mb 60<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Redis calls an internal function to perform many background tasks, like<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># closing connections of clients in timeot, purging expired keys that are<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># never requested, and so forth.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Not all tasks are perforemd with the same frequency, but Redis checks for<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># tasks to perform accordingly to the specified &#8220;hz&#8221; value.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># By default &#8220;hz&#8221; is set to 10. Raising the value will use more CPU when<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Redis is idle, but at the same time will make Redis more responsive when<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># there are many keys expiring at the same time, and timeouts may be<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># handled with more precision.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># The range is between 1 and 500, however a value over 100 is usually not<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># a good idea. Most users should use the default of 10 and raise this up to<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># 100 only in environments where very low latency is required.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">hz 10<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># When a child rewrites the AOF file, if the following option is enabled<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># the file will be fsync-ed every 32 MB of data generated. This is useful<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># in order to commit the file to the disk more incrementally and avoid<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># big latency spikes.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">aof-rewrite-incremental-fsync yes<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">################################## INCLUDES ###################################<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">\u00a0<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># Include one or more other config files here.\u00a0 This is useful if you<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># have a standard template that goes to all Redis server but also need<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># to customize a few per-server settings.\u00a0 Include files can include<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># other files, so use this wisely.<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\">#<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># include \/path\/to\/local.conf<\/span><\/div>\n<div align=\"left\"><span style=\"color: #010101;\"># include \/path\/to\/other.conf<\/span><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5Redis Redis\u7684\u4ecb\u7ecd: redis\u662f\u4e00\u4e2a\u5f00\u6e90\u7684key-value\u6570\u636e\u5e93,\u5b83\u53c8\u7ecf\u5e38\u88ab\u8ba4\u4e3a\u662f\u4e00\u4e2a\u6570\u636e\u7ed3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[25,26],"class_list":["post-327","post","type-post","status-publish","format-standard","hentry","category-nosql","tag-nosql","tag-redis"],"_links":{"self":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts\/327","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=327"}],"version-history":[{"count":0,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=\/wp\/v2\/posts\/327\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=327"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=327"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.royalwzy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=327"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}