提交 6674e3b9 编写于 作者: A antirez

added new HTML doc pages

上级 b9f7e9e6
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>BrpoplpushCommand: Contents</b><br>&nbsp;&nbsp;<a href="#BRPOPLPUSH _srckey_ _dstkey_ _timeout_ (Redis &gt;">BRPOPLPUSH _srckey_ _dstkey_ _timeout_ (Redis &gt;</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Return value">Return value</a>
</div>
<h1 class="wikiname">BrpoplpushCommand</h1>
<div class="summary">
</div>
<div class="narrow">
<h1><a name="BRPOPLPUSH _srckey_ _dstkey_ _timeout_ (Redis &gt;">BRPOPLPUSH _srckey_ _dstkey_ _timeout_ (Redis &gt;</a></h1> 2.1.8) =
<i>Time complexity: O(1)</i><blockquote>Blocking version of the <a href="RpoplpushCommand.html">RPOPLPUSH</a> command. Atomically removes and returnsthe last element (tail) of the source list at <i>srckey</i>, and as a side effect pushes the returned element in the head of the list at <i>dstkey</i>.</blockquote>
If the source list is empty, the client blocks until another client pushes against the source list. Of course in such a case the push operation against the destination list will be performed after the command unblocks detecting a push against the source list.<br/><br/>Note that the command returns an error if the target key already exists but is not a list. The error is delayed at the time the push operation is attempted, that is, immediately if the source list is not empty, or when the first push against the source list happens in the case the command would block.<br/><br/>The timeout value can be 0 or a positive integer value. When it is zero the command will block forever, until something is pushed against <i>srckey</i>. Otherwise the command will wait the specified number of seconds at max, returning an nil value when the timeout expires.<br/><br/>The source and destination of the list can be the same, having the effect of rotating the list. Please check <a href="RpoplpushCommand.html">RPOPLPUSH</a> for more information.<h2><a name="Return value">Return value</a></h2><a href="ReplyTypes.html">Bulk reply</a>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>GetbitCommand: Contents</b><br>&nbsp;&nbsp;<a href="#GETBIT _key_ _offset_ (Redis &gt;">GETBIT _key_ _offset_ (Redis &gt;</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Return value">Return value</a>
</div>
<h1 class="wikiname">GetbitCommand</h1>
<div class="summary">
</div>
<div class="narrow">
<h1><a name="GETBIT _key_ _offset_ (Redis &gt;">GETBIT _key_ _offset_ (Redis &gt;</a></h1> 2.1.8) =
<i>Time complexity: O(1)</i><blockquote>Returns the bit value at <i>offset</i> in the string value stored at <i>key</i>.</blockquote>
When <i>offset</i> is beyond the string length, the string is assumed to be a contiguous space with 0 bits. When <i>key</i> does not exist it is assumed to be an empty string, so <i>offset</i> is always out of range and the value is also assumed to be a contiguous space with 0 bits.<h2><a name="Return value">Return value</a></h2><a href="ReplyTypes.html">Integer reply</a>, specifically: the bit value stored at <i>offset</i>.
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>HmgetCommand: Contents</b><br>&nbsp;&nbsp;<a href="#HMGET _key_ _field1_ ... _fieldN_ (Redis &gt;">HMGET _key_ _field1_ ... _fieldN_ (Redis &gt;</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Return value">Return value</a>
</div>
<h1 class="wikiname">HmgetCommand</h1>
<div class="summary">
</div>
<div class="narrow">
&iuml;&raquo;&iquest;#sidebar <a href="HashCommandsSidebar.html">HashCommandsSidebar</a><h1><a name="HMGET _key_ _field1_ ... _fieldN_ (Redis &gt;">HMGET _key_ _field1_ ... _fieldN_ (Redis &gt;</a></h1> 1.3.10) =
<i>Time complexity: O(N) (with N being the number of fields)</i><blockquote>Retrieve the values associated to the specified <i>fields</i>.</blockquote>
<blockquote>If some of the specified <i>fields</i> do not exist, nil values are returned.Non existing keys are considered like empty hashes.</blockquote>
<h2><a name="Return value">Return value</a></h2><a href="ReplyTypes.html">Multi Bulk Reply</a> specifically a list of all the values associated with the specified fields, in the same order of the request.
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>NonexistentCommands: Contents</b><br>&nbsp;&nbsp;<a href="#HGETSET">HGETSET</a><br>&nbsp;&nbsp;<a href="#SET with expire">SET with expire</a><br>&nbsp;&nbsp;<a href="#ZADDNX">ZADDNX</a>
</div>
<h1 class="wikiname">NonexistentCommands</h1>
<div class="summary">
A list of commands that don't exist in Redis, but can be accomplished in a different way.
</div>
<div class="narrow">
This is a list of commands that don't exist in Redis, but can be accomplished in a different way, usually by means of <a href="MultiExecCommand.html">WATCH/MULTI/EXEC</a>.<br/><br/>For better performance, you can pipeline multiple commands.<h1><a name="HGETSET">HGETSET</a></h1><a href="GetsetCommand.html">GETSET</a> for Hashes.<br/><br/><pre class="codeblock python" name="code">
WATCH foo
old_value = HGET foo field
MULTI
HSET foo field new_value
EXEC
</pre><h1><a name="SET with expire">SET with expire</a></h1>See <a href="SetexCommand.html">SETEX</a>.<h1><a name="ZADDNX">ZADDNX</a></h1>Add an element to a sorted set, only if the element doesn't already exist (by default, <a href="ZaddCommand.html">ZADD</a> would update the element's score if it already exists). <a href="http://groups.google.com/group/redis-db/browse_thread/thread/fc4c79d72e5bd346/6cdc07ecc36b81e7" target="_blank">See thread</a>.<br/><br/><pre class="codeblock python python" name="code">
WATCH foo
score = ZSCORE foo bar
IF score != NIL
MULTI
ZADD foo 1 bar
EXEC
ENDIF
</pre>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>RedisCLI: Contents</b><br>&nbsp;&nbsp;<a href="#Redis CLI">Redis CLI</a>
</div>
<h1 class="wikiname">RedisCLI</h1>
<div class="summary">
Redis Command Line Interface
</div>
<div class="narrow">
<h1><a name="Redis CLI">Redis CLI</a></h1>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>RedisPipelining: Contents</b><br>&nbsp;&nbsp;<a href="#Request/Response protocols and RTT">Request/Response protocols and RTT</a><br>&nbsp;&nbsp;<a href="#Redis Pipelining">Redis Pipelining</a><br>&nbsp;&nbsp;<a href="#Some benchmark">Some benchmark</a><br>&nbsp;&nbsp;<a href="#Pipelining VS other multi-commands">Pipelining VS other multi-commands</a>
</div>
<h1 class="wikiname">RedisPipelining</h1>
<div class="summary">
</div>
<div class="narrow">
<h1><a name="Request/Response protocols and RTT">Request/Response protocols and RTT</a></h1>
Redis is a TCP server using the client-server model and what is called a <b>Request/Response</b> protocol.<br/><br/>This means that usually a request is accomplished with the following steps:
<ul><li> The client sends a query to the server, and reads from the socket, usually in a blocking way, for the server response.</li><li> The server processes the command and sends the response back to the server.</li></ul>So for instance a four commands sequence is something like this:
<ul><li> <b>Client:</b> INCR X</li><li> <b>Server:</b> 1</li><li> <b>Client:</b> INCR X</li><li> <b>Server:</b> 2</li><li> <b>Client:</b> INCR X</li><li> <b>Server:</b> 3</li><li> <b>Client:</b> INCR X</li><li> <b>Server:</b> 4</li></ul>Clients and Servers are connected via a networking link. Such a link can be very fast (a loopback interface) or very slow (a connection established over the internet with many hops between the two hosts). Whatever the network latency is, there is a time for the packets to travel from the client to the server, and back from the server to the client to carry the reply.<br/><br/>This time is called RTT (Round Trip Time). It is very easy to see how this can affect the performances when a client needs to perform many requests in a row (for instance adding many elements to the same list, or populating a database with many keys). For instance if the RTT time is 250 milliseconds (in the case of a very slow link over the internet), even if the server is able to process 100k requests per second, we'll be able to process at max four requests per second.<br/><br/>If the interface used is a loopback interface, the RTT is much shorter (for instance my host reports 0,044 milliseconds pinging 127.0.0.1), but it is still a lot if you need to perform many writes in a row.<br/><br/>Fortunately there is a way to improve this use cases.
<h1><a name="Redis Pipelining">Redis Pipelining</a></h1>
A Request/Response server can be implemented so that it is able to process new requests even if the client didn't already read the old responses. This way it is possible to send <b>multiple commands</b> to the server without waiting for the replies at all, and finally read the replies in a single step.<br/><br/>This is called pipelining, and is a technique widely in use since many decades. For instance many POP3 protocol implementations already supported this feature, dramatically speeding up the process of downloading new emails from the server.<br/><br/>Redis supports pipelining since the very early days, so whatever version you are running, you can use pipelining with Redis. This is an example using the raw netcat utility:
<pre class="codeblock python" name="code">
$ (echo -en &quot;PING\r\nPING\r\nPING\r\n&quot;; sleep 1) | nc localhost 6379
+PONG
+PONG
+PONG
</pre>
This time we are not paying the cost of RTT for every call, but just one time for the three commands.<br/><br/>To be very explicit, with pipelining the order of operations of our very first example will be the following:
<ul><li> <b>Client:</b> INCR X</li><li> <b>Client:</b> INCR X</li><li> <b>Client:</b> INCR X</li><li> <b>Client:</b> INCR X</li><li> <b>Server:</b> 1</li><li> <b>Server:</b> 2</li><li> <b>Server:</b> 3</li><li> <b>Server:</b> 4</li></ul><b>IMPORTANT NOTE</b>: while the client sends commands using pipelining, the server will be forced to queue the replies, using memory. So if you need to send many many commands with pipelining it's better to send this commands up to a given reasonable number, for instance 10k commands, read the replies, and send again other 10k commands and so forth. The speed will be nearly the same, but the additional memory used will be at max the amount needed to queue the replies for this 10k commands.
<h1><a name="Some benchmark">Some benchmark</a></h1>
In the following benchmark we'll use the Redis Ruby client, supporting pipelining, to test the speed improvement due to pipelining:
<pre class="codeblock python python" name="code">
require 'rubygems'
require 'redis'
def bench(descr)
start = Time.now
yield
puts &quot;#{descr} #{Time.now-start} seconds&quot;
end
def without_pipelining
r = Redis.new
10000.times {
r.ping
}
end
def with_pipelining
r = Redis.new
r.pipelined {
10000.times {
r.ping
}
}
end
bench(&quot;without pipelining&quot;) {
without_pipelining
}
bench(&quot;with pipelining&quot;) {
with_pipelining
}
</pre>
Running the above simple script will provide this figures in my Mac OS X system, running over the loopback interface, where pipelining will provide the smallest improvement as the RTT is already pretty low:
<pre class="codeblock python python python" name="code">
without pipelining 1.185238 seconds
with pipelining 0.250783 seconds
</pre>
As you can see using pipelining we improved the transfer by a factor of five.
<h1><a name="Pipelining VS other multi-commands">Pipelining VS other multi-commands</a></h1>
Often we get requests about adding new commands performing multiple operations in a single pass.
For instance there is no command to add multiple elements in a set. You need calling many times SADD.<br/><br/>With pipelining you can have performances near to an MSADD command, but at the same time we'll avoid bloating the Redis command set with too many commands. An additional advantage is that the version written using just SADD will be ready for a distributed environment (for instance Redis Cluster, that is in the process of being developed) just dropping the pipelining code.
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>RedisStatus: Contents</b><br>&nbsp;&nbsp;<a href="#Redis Status Page">Redis Status Page</a><br>&nbsp;&nbsp;<a href="#How stable are the alpha previews?">How stable are the alpha previews?</a><br>&nbsp;&nbsp;<a href="#How to obtain a 2.2-alpha preview">How to obtain a 2.2-alpha preview</a><br>&nbsp;&nbsp;<a href="#ETA for Redis 2.2?">ETA for Redis 2.2?</a><br>&nbsp;&nbsp;<a href="#When will we be able to see a working version of Redis Cluster?">When will we be able to see a working version of Redis Cluster?</a>
</div>
<h1 class="wikiname">RedisStatus</h1>
<div class="summary">
</div>
<div class="narrow">
<h1><a name="Redis Status Page">Redis Status Page</a></h1>Hello! Redis uses versions composed of three numbers separated by a dot: <b>major</b>.<b>minor</b>.<b>patchlevel</b>.<br/><br/>When the <b>minor</b> is an odd number, it is used for an unstable release, so stable releases are for instance 1.2, 2.0, and so forth.<br/><br/>This is the status of the different Redis versions currently available:<br/><br/><ul><li> 1.2 is the <b>legacy redis stable release</b>, now it is completely obsoleted by Redis 2.0. Redis 2.0 is almost completely back compatible with 1.2 so upgrading is usually not a problem. Still 1.2 is believed to be a very stable release that works well, so if you are using it in production with code that probably will not modified to use more advanced Redis features available in 2.0, it makes sense to take 1.2 running. For everything new, it's better to start with 2.0.</li></ul>
<ul><li> 2.0 is the current <b>stable release</b>. It is better than 1.2 in more or less everything: more features, more mature code, better replication, better persistence, and so forth. It is currently what most users should use, unless they really need features that are only available into an <b>unstable</b> release.</li></ul>
<ul><li> 2.1 is the current <b>unstable release</b>, and there are no tar.gz for this release, you need to download it from git. <b>Warning:</b> the master branch in git may work most of the time but is NOT what you should use. What's better instead is to use the 2.2-alpha tags: every time Redis 2.1.x is stable enough and the new features merged passed all the tests for a couple of weeks, and we didn't received severe bug reports from users, we tag master as 2.2-alpha <i>number</i>, where <i>number</i> is simply a progressive number. Just pick this number.</li></ul>
<h1><a name="How stable are the alpha previews?">How stable are the alpha previews?</a></h1>
Well it is surely ok for development, but it is not recommended for production. Still there are many users that trust Redis development process so much to use alpha releases in production, but this is up to you, we don't give any guarantee ;)<h1><a name="How to obtain a 2.2-alpha preview">How to obtain a 2.2-alpha preview</a></h1>Simply using git:
<pre class="codeblock python" name="code">
$ git clone git://github.com/antirez/redis.git
Initialized empty Git repository in /tmp/redis/.git/
...
</pre>
Then you can list all the branches matching 2.1-alpha with:
<pre class="codeblock python python" name="code">
cd redis
$ git tag | grep 2.2-alpha
2.2-alpha0
2.2-alpha1
2.2-alpha2
</pre>
At this point you can just use <b>git checkout <i>tagname</i></b>, substituting <i>tagname</i> with 2.2-alphaX where X is the greater progressive number you see in the listing.<h1><a name="ETA for Redis 2.2?">ETA for Redis 2.2?</a></h1>
Redis 2.2 is planned to enter the release candidate stage before the end of the 2010.<h1><a name="When will we be able to see a working version of Redis Cluster?">When will we be able to see a working version of Redis Cluster?</a></h1>
I'm already working at it, I mean not just designing, but writing code. In three months we should have some kind of experimental version, while in six months we should have the first release candidate.<br/><br/>Probably the first <b>stable</b> release of Redis with working cluster will be called 3.0, but I'll try to merge it into 2.2 as an experimental support if we'll be sure there is no impact in the stability of the system when clustering is not used.
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>Redis_2_0_0_Changelog: Contents</b><br>&nbsp;&nbsp;<a href="#Redis 2.0: What's new?">Redis 2.0: What's new?</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#MULTI/EXEC">MULTI/EXEC</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Blocking pop">Blocking pop</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Publish/subscribe">Publish/subscribe</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Hashes">Hashes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Virtual Memory">Virtual Memory</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Contributors">Contributors</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Special Thanks">Special Thanks</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#DOWNLOAD">DOWNLOAD</a>
</div>
<h1 class="wikiname">Redis_2_0_0_Changelog</h1>
<div class="summary">
</div>
<div class="narrow">
<h1><a name="Redis 2.0: What's new?">Redis 2.0: What's new?</a></h1>The release of Redis 2.0 marks a major milestone in Redis development. Apart from an endless list of new features, there are some major ones that deserve to be highlighted.<br/><br/>It's worth to mention that while Redis 2.0.0 just reached its first stable release, Redis 2.2.0 is near to reach feature freeze, so ... be prepared for new exiting things in very short time!<h3><a name="MULTI/EXEC">MULTI/EXEC</a></h3>
The MULTI/EXEC family of commands were added to fulfill the need to execute multiple commands as a single atomic block.
Because all commands inside a MULTI/EXEC block are serialized and executed sequentially, it is not possible that another
client request is served in the middle of executing this block. All commands are executed one after the other when
EXEC is called, which makes sure either <b>all</b> or <b>no</b> commands are executed, independent of the state of the client connection.<br/><br/>More on MULTI/EXEC:
<ul><li> <a href="http://code.google.com/p/redis/wiki/MultiExecCommand" target="_blank">http://code.google.com/p/redis/wiki/MultiExecCommand</a></li></ul>
Note that WATCH, a CAS (check and set) variant of MULTI/EXEC will be available on 2.2.0 and is not part of 2.0.0.<h3><a name="Blocking pop">Blocking pop</a></h3>
The commands BLPOP and BRPOP were added to support popping from a list in a blocking fashion. This means the client
connection will be blocked for a certain amount of time until another client pushes an item on a list. These commands
are frequently used in producer/consumer scenarios.<br/><br/>More on blocking pop:
<ul><li> <a href="http://code.google.com/p/redis/wiki/BlpopCommand" target="_blank">http://code.google.com/p/redis/wiki/BlpopCommand</a></li></ul>
<h3><a name="Publish/subscribe">Publish/subscribe</a></h3>
The family of publish/subscribe commands let clients publish messages onto channels and subscribe to receive all messages
that are published on channels. Also included are commands to receive all messages for which the channel matches a given pattern.<br/><br/>More on publish/subscribe:
<ul><li> <a href="http://code.google.com/p/redis/wiki/PublishSubscribe" target="_blank">http://code.google.com/p/redis/wiki/PublishSubscribe</a></li><li> <a href="http://antirez.com/post/redis-weekly-update-3-publish-submit.html" target="_blank">http://antirez.com/post/redis-weekly-update-3-publish-submit.html</a></li><li> <a href="http://rediscookbook.org/pubsub_for_asynchronous_communication.html" target="_blank">http://rediscookbook.org/pubsub_for_asynchronous_communication.html</a></li></ul>
<h3><a name="Hashes">Hashes</a></h3>
This new datatype allows to store multiple key/value pairs on a single key. Together with the list of regular commands you
would expect for such a datatype (HSET, HGET, HDEL, HLEN, HKEYS, ...), it is also possible to use the values <i>inside</i> a hash
for any SORT operation.<br/><br/>More on hashes:
<ul><li> <a href="http://code.google.com/p/redis/wiki/HsetCommand" target="_blank">http://code.google.com/p/redis/wiki/HsetCommand</a></li><li> <a href="http://antirez.com/post/redis-weekly-update-1.html" target="_blank">http://antirez.com/post/redis-weekly-update-1.html</a></li></ul>
<h3><a name="Virtual Memory">Virtual Memory</a></h3>
Redis Virtual Memory allows users to grow their dataset beyond the limits of their RAM.<br/><br/>More on virtual memory:
<ul><li> <a href="http://code.google.com/p/redis/wiki/VirtualMemoryUserGuide" target="_blank">http://code.google.com/p/redis/wiki/VirtualMemoryUserGuide</a></li><li> <a href="http://antirez.com/post/redis-virtual-memory-story.html" target="_blank">http://antirez.com/post/redis-virtual-memory-story.html</a></li></ul>
<h3><a name="Contributors">Contributors</a></h3><ul><li> Salvatore Sanfilippo</li><li> Pieter Noordhuis</li><li> Antonio Ognio</li><li> Alex McHale</li><li> Michel Martens</li><li> Damian Janowski</li><li> Bruno Deferrari</li><li> Ashley Martens</li><li> Derek Collison</li><li> Damian Janowski</li><li> Jeremy Zawodny</li><li> Konstantin Merenkov</li><li> Michel Martens</li><li> Sam Hendley</li></ul>
<h3><a name="Special Thanks">Special Thanks</a></h3>
Thanks to VMware sponsoring the work of Salvatore and Pieter, and the Redis community of users and client library developers. Redis 2.0.0 was possible only thanks to your support.<h3><a name="DOWNLOAD">DOWNLOAD</a></h3>
You can grab Redis 2.0.0 from <a href="http://code.google.com/p/redis/downloads/list" target="_blank">Google Code</a>.<br/><br/>It is also tagged on Git.
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>Redis_2_0_Whats_new: Contents</b><br>&nbsp;&nbsp;<a href="#Redis 2.0: What's new?">Redis 2.0: What's new?</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#MULTI/EXEC">MULTI/EXEC</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Blocking pop">Blocking pop</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Publish/subscribe">Publish/subscribe</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Hashes">Hashes</a><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Virtual Memory">Virtual Memory</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Contributors">Contributors</a>
</div>
<h1 class="wikiname">Redis_2_0_Whats_new</h1>
<div class="summary">
</div>
<div class="narrow">
<h1><a name="Redis 2.0: What's new?">Redis 2.0: What's new?</a></h1>The release of Redis 2.0 marks a major milestone in Redis development. Apart from an endless list of new features, there are some major ones that deserve to be highlighted.<h3><a name="MULTI/EXEC">MULTI/EXEC</a></h3>
The MULTI/EXEC family of commands were added to fulfill the need to execute multiple commands as a single atomic block.
Because all commands inside a MULTI/EXEC block are serialized and executed sequentially, it is not possible that another
client request is served in the middle of executing this block. All commands are executed one after the other when
EXEC is called, which makes sure either <b>all</b> or <b>no</b> commands are executed, independent of the state of the client connection.<br/><br/>More on MULTI/EXEC:
<ul><li> <a href="http://code.google.com/p/redis/wiki/MultiExecCommand" target="_blank">http://code.google.com/p/redis/wiki/MultiExecCommand</a></li></ul>
<h3><a name="Blocking pop">Blocking pop</a></h3>
The commands BLPOP and BRPOP were added to support popping from a list in a blocking fashion. This means the client
connection will be blocked for a certain amount of time until another client pushes an item on a list. These commands
are frequently used in producer/consumer scenarios.<br/><br/>More on blocking pop:
<ul><li> <a href="http://code.google.com/p/redis/wiki/BlpopCommand" target="_blank">http://code.google.com/p/redis/wiki/BlpopCommand</a></li></ul>
<h3><a name="Publish/subscribe">Publish/subscribe</a></h3>
The family of publish/subscribe commands let clients publish messages onto channels and subscribe to receive all messages
that are published on channels. Also included are commands to receive all messages for which the channel matches a given pattern.<br/><br/>More on publish/subscribe:
<ul><li> <a href="http://code.google.com/p/redis/wiki/PublishSubscribe" target="_blank">http://code.google.com/p/redis/wiki/PublishSubscribe</a></li><li> <a href="http://antirez.com/post/redis-weekly-update-3-publish-submit.html" target="_blank">http://antirez.com/post/redis-weekly-update-3-publish-submit.html</a></li><li> <a href="http://rediscookbook.org/pubsub_for_asynchronous_communication.html" target="_blank">http://rediscookbook.org/pubsub_for_asynchronous_communication.html</a></li></ul>
<h3><a name="Hashes">Hashes</a></h3>
This new datatype allows to store multiple key/value pairs on a single key. Together with the list of regular commands you
would expect for such a datatype (HSET, HGET, HDEL, HLEN, HKEYS, ...), it is also possible to use the values <i>inside</i> a hash
for any SORT operation.<br/><br/>More on hashes:
<ul><li> <a href="http://code.google.com/p/redis/wiki/HsetCommand" target="_blank">http://code.google.com/p/redis/wiki/HsetCommand</a></li><li> <a href="http://antirez.com/post/redis-weekly-update-1.html" target="_blank">http://antirez.com/post/redis-weekly-update-1.html</a></li></ul>
<h3><a name="Virtual Memory">Virtual Memory</a></h3>
Redis Virtual Memory allows users to grow their dataset beyond the limits of their RAM.<br/><br/>More on virtual memory:
<ul><li> <a href="http://code.google.com/p/redis/wiki/VirtualMemoryUserGuide" target="_blank">http://code.google.com/p/redis/wiki/VirtualMemoryUserGuide</a></li><li> <a href="http://antirez.com/post/redis-virtual-memory-story.html" target="_blank">http://antirez.com/post/redis-virtual-memory-story.html</a></li></ul>
<h2><a name="Contributors">Contributors</a></h2><ul><li> Salvatore Sanfilippo</li><li> Pieter Noordhuis</li><li> Antonio Ognio</li><li> Alex McHale</li><li> Michel Martens</li><li> Damian Janowski</li><li> Bruno Deferrari</li><li> Ashley Martens</li><li> Derek Collison</li><li> Damian Janowski</li><li> Jeremy Zawodny</li><li> Konstantin Merenkov</li><li> Michel Martens</li><li> Sam Hendley</li></ul>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>SetbitCommand: Contents</b><br>&nbsp;&nbsp;<a href="#SETBIT _key_ _offset_ _value_ (Redis &gt;">SETBIT _key_ _offset_ _value_ (Redis &gt;</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Return value">Return value</a>
</div>
<h1 class="wikiname">SetbitCommand</h1>
<div class="summary">
</div>
<div class="narrow">
<h1><a name="SETBIT _key_ _offset_ _value_ (Redis &gt;">SETBIT _key_ _offset_ _value_ (Redis &gt;</a></h1> 2.1.8) =
<i>Time complexity: O(1)</i><blockquote>Sets or clears the bit at <i>offset</i> in the string value stored at <i>key</i>.</blockquote>
The bit is either set or cleared depending on <i>value</i>, which can be either 0 or 1. When <i>key</i> does not exist, a new string value is created. The string is grown to make sure it can hold a bit at <i>offset</i>. The <i>offset</i> argument is required to be greater than or equal to 0, and is limited to 2<sup>32-1 (which limits bitmaps to 512MB).
When the string at <i>key</i> is grown, added bits are set to 0.<br/><br/><b>Warning</b>: When setting the last possible bit (<i>offset</i> equal to 2</sup>32-1) and the string value stored at <i>key</i> does not yet hold a string value, or holds a small string value, Redis needs to allocate all intermediate memory which can block the server for some time.
On a 2010 Macbook Pro, setting bit number 2<sup>32-1 (512MB allocation) takes ~300ms,
setting bit number 2</sup>30-1 (128MB allocation) takes ~80ms,
setting bit number 2<sup>28-1 (32MB allocation) takes ~30ms and
setting bit number 2</sup>26-1 (8MB allocation) takes ~8ms.
Note that once this first allocation is done, subsequent calls to SETBIT for the same <i>key</i> will not have the allocation overhead.<h2><a name="Return value">Return value</a></h2><a href="ReplyTypes.html">Integer reply</a>, specifically: the original bit value stored at <i>offset</i>.
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>SetrangeCommand: Contents</b><br>&nbsp;&nbsp;<a href="#SETRANGE _key_ _offset_ _value_ (Redis &gt;">SETRANGE _key_ _offset_ _value_ (Redis &gt;</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Examples">Examples</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Patterns">Patterns</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Return value">Return value</a>
</div>
<h1 class="wikiname">SetrangeCommand</h1>
<div class="summary">
</div>
<div class="narrow">
&iuml;&raquo;&iquest;#sidebar <a href="StringCommandsSidebar.html">StringCommandsSidebar</a><h1><a name="SETRANGE _key_ _offset_ _value_ (Redis &gt;">SETRANGE _key_ _offset_ _value_ (Redis &gt;</a></h1> 2.1.8) =
<i>Time complexity: O(1) not counting the time taken to copy the new string in place, as usually this string is small so the amoritzed time is O(1). Otheriwse O(M) with M being the length of the value argument</i><blockquote>Overwrites part of a string at <i>key</i> starting at the specified offset,for all the length of <i>value</i>.If the offset is over the old length of the string, the string is paddedwith zero bytes until needed. Non existing keys are considered likealready containing an empty string.</blockquote>
<h2><a name="Examples">Examples</a></h2>First example, basic usage setting a range.<br/><br/><pre class="codeblock python" name="code">
redis&gt; set foo &quot;Hello World&quot;
OK
redis&gt; setrange foo 6 &quot;Redis&quot;
(integer) 11
redis&gt; get foo
&quot;Hello Redis&quot;
</pre>Example of the zero padding behavior.<br/><br/><pre class="codeblock python python" name="code">
redis&gt; del foo
(integer) 1
redis&gt; setrange foo 10 bar
(integer) 13
redis&gt; get foo
&quot;\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00bar&quot;
</pre>Note that the maximum offset that you can set is 536870911 as Redis Strings are limited to 512 megabytes. You can still create longer arrays of values using multiple keys.<br/><br/><b>Warning</b>: When setting the last possible byte and the string value stored at <i>key</i> does not yet hold a string value, or holds a small string value, Redis needs to allocate all intermediate memory which can block the server for some time.
On a 2010 Macbook Pro, setting byte number 536870911 (512MB allocation) takes ~300ms,
setting byte number 134217728 (128MB allocation) takes ~80ms,
setting bit number 33554432 (32MB allocation) takes ~30ms and
setting bit number 8388608 (8MB allocation) takes ~8ms.
Note that once this first allocation is done, subsequent calls to SETRANGE for the same <i>key</i> will not have the allocation overhead.<h2><a name="Patterns">Patterns</a></h2>Thanks to SETRANGE and the analogous GETRANGE command you can use Redis strings as a linear array of memory with O(1) random access. This is a very fast and efficient storage in many real world use cases.<h2><a name="Return value">Return value</a></h2><a href="ReplyTypes.html">Integer reply</a>, specifically: the length of the string after it was modified by the command.
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<link type="text/css" rel="stylesheet" href="style.css" />
</head>
<body>
<div id="page">
<div id='header'>
<a href="index.html">
<img style="border:none" alt="Redis Documentation" src="redis.png">
</a>
</div>
<div id="pagecontent">
<div class="index">
<!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. -->
<b>StrlenCommand: Contents</b><br>&nbsp;&nbsp;<a href="#STRLEN _key_ (Redis &gt;">STRLEN _key_ (Redis &gt;</a><br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#Return value">Return value</a>
</div>
<h1 class="wikiname">StrlenCommand</h1>
<div class="summary">
</div>
<div class="narrow">
&iuml;&raquo;&iquest;#sidebar <a href="StringCommandsSidebar.html">StringCommandsSidebar</a><h1><a name="STRLEN _key_ (Redis &gt;">STRLEN _key_ (Redis &gt;</a></h1> 2.1.8) =
<i>Time complexity: O(1)</i><blockquote>Returns the length of the string stored at the specified <i>key</i>.</blockquote>
<h2><a name="Return value">Return value</a></h2><a href="ReplyTypes.html">Integer reply</a>, specifically: the length of the string.
</div>
</div>
</div>
</body>
</html>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册