code: def set(self, key, value, ex=None, px=None, nx=False, xx=False):
          
          key = self._encode(key)
          value = self._encode(value)
  
          if nx and xx:
              return None
          mode = "nx" if nx else "xx" if xx else None
          if self._should_set(key, mode):
              expire = None
              if ex is not None:
                  expire = ex if isinstance(ex, timedelta) else timedelta(seconds=ex)
              if px is not None:
                  expire = px if isinstance(px, timedelta) else timedelta(milliseconds=px)
  
              if expire is not None and expire.total_seconds() <= 0:
                  raise ResponseError("invalid expire time in SETEX")
  
              result = self._set(key, value)
              if expire:
                  self._expire(key, expire)
  
              return result
docs: Set the ``value`` for the ``key`` in the context of the provided kwargs.
  
          As per the behavior of the redis-py lib:
          If nx and xx are both set, the function does nothing and None is returned.
          If px and ex are both set, the preference is given to px.
          If the key is not set for some reason, the lib function returns None.