code: def setbit(self, key, offset, value):
          
          key = self._encode(key)
          index, bits, mask = self._get_bits_and_offset(key, offset)
  
          if index >= len(bits):
              bits.extend(b"\x00" * (index + 1 - len(bits)))
  
          prev_val = 1 if (bits[index] & mask) else 0
  
          if value:
              bits[index] |= mask
          else:
              bits[index] &= ~mask
  
          self.redis[key] = bytes(bits)
  
          return prev_val
docs: Set the bit at ``offset`` in ``key`` to ``value``.