setBit 命令/方法/函数

Description

Changes a single bit of a string.


Parameters

key

offset

value: bool or int (1 or 0)


Return value

LONG: 0 or 1, the value of the bit before it was set.


Example

$redis->set('key', "*");    // ord("*") = 42 = 0x2f = "0010 1010"

$redis->setBit('key', 5, 1); /* returns 0 */

$redis->setBit('key', 7, 1); /* returns 0 */

$redis->get('key'); /* chr(0x2f) = "/" = b("0010 1111") */