6674e3b9 |
1 | |
2 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> |
3 | <html> |
4 | <head> |
5 | <link type="text/css" rel="stylesheet" href="style.css" /> |
6 | </head> |
7 | <body> |
8 | <div id="page"> |
9 | |
10 | <div id='header'> |
11 | <a href="index.html"> |
12 | <img style="border:none" alt="Redis Documentation" src="redis.png"> |
13 | </a> |
14 | </div> |
15 | |
16 | <div id="pagecontent"> |
17 | <div class="index"> |
18 | <!-- This is a (PRE) block. Make sure it's left aligned or your toc title will be off. --> |
19 | <b>SetbitCommand: Contents</b><br> <a href="#SETBIT _key_ _offset_ _value_ (Redis >">SETBIT _key_ _offset_ _value_ (Redis ></a><br> <a href="#Return value">Return value</a> |
20 | </div> |
21 | |
22 | <h1 class="wikiname">SetbitCommand</h1> |
23 | |
24 | <div class="summary"> |
25 | |
26 | </div> |
27 | |
28 | <div class="narrow"> |
29 | |
30 | <h1><a name="SETBIT _key_ _offset_ _value_ (Redis >">SETBIT _key_ _offset_ _value_ (Redis ></a></h1> 2.1.8) = |
31 | <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> |
32 | 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). |
33 | 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. |
34 | On a 2010 Macbook Pro, setting bit number 2<sup>32-1 (512MB allocation) takes ~300ms, |
35 | setting bit number 2</sup>30-1 (128MB allocation) takes ~80ms, |
36 | setting bit number 2<sup>28-1 (32MB allocation) takes ~30ms and |
37 | setting bit number 2</sup>26-1 (8MB allocation) takes ~8ms. |
38 | 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>. |
39 | </div> |
40 | |
41 | </div> |
42 | </div> |
43 | </body> |
44 | </html> |
45 | |