Read a book see Redis bit operations related content, there is an example:
For example, every user of the site has a self-increment ID, using a String type of key-bit operation to record the user's gender ..., I want to know this record of the way specific operation, or what is the idea, I know that there must be a difference between the 1 and the% of the bits, but how is it recorded?
Reply content:
Read a book see Redis bit operations related content, there is an example: For example, every user of the site has a self-increment ID, using a String type of key-bit operation to record the user's gender ..., I want to know this record of the way specific operation, or what is the idea, I know that there must be a difference between the 1 and the% of the bits, but how is it recorded?
setbit key offset
, where offset is replaced with UserID, if the user with ID 1 is male setbit key 1 1
, and if it is female setbit key 1 0
, get the gender of ID 1getbit key 1
$redis->mSet($userId,['age'=>18, 'gender'=>0]);//小明$redis->mSet($userId2,['age'=>16, 'gender'=>1]);//小红$user = $redis->mGet($userId);echo $user['gender'];//