code: def _should_set(self, key, mode):
          
  
          if mode is None or mode not in ["nx", "xx"]:
              return True
  
          if mode == "nx":
              if key in self.redis:
                  # nx means set only if key is absent
                  # false if the key already exists
                  return False
          elif key not in self.redis:
              # at this point mode can only be xx
              # xx means set only if the key already exists
              # false if is absent
              return False
          # for all other cases, return true
          return True
docs: Determine if it is okay to set a key.
  
          If the mode is None, returns True, otherwise, returns True of false based on
          the value of ``key`` and the ``mode`` (nx | xx).