mirror of
http://github.com/valkey-io/valkey
synced 2024-11-22 00:52:38 +00:00
46 lines
2.5 KiB
HTML
46 lines
2.5 KiB
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> <a href="#SETBIT _key_ _offset_ _value_ (Redis >">SETBIT _key_ _offset_ _value_ (Redis ></a><br> <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 >">SETBIT _key_ _offset_ _value_ (Redis ></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>
|
||
|
|