code: def _get_by_type(self, key, operation, create, type_, default, return_default=True):
          
          key = self._encode(key)
          if self.type(key) in [type_, b'none']:
              if create:
                  return self.redis.setdefault(key, default)
              else:
                  return self.redis.get(key, default if return_default else None)
  
          raise TypeError("{} requires a {}".format(operation, type_))
docs: Get (and maybe create) a redis data structure by name and type.