redis-om-python icon indicating copy to clipboard operation
redis-om-python copied to clipboard

.save() downstream runs Redis SET with nx=False as the default, how do I run .save() such that downstream it runs a SET op with nx=True

Open pramttl opened this issue 7 months ago • 0 comments

There seems to be no direct way in Redis OM to relay nx from .save() to the underlying Redis SET call.

In the Redis OM source this is what the save looks like:

    def save(
        self: "Model", pipeline: Optional[redis.client.Pipeline] = None
    ) -> "Model":
        self.check()
        db = self._get_db(pipeline)

        db.json().set(self.key(), Path.root_path(), json.loads(self.json()))
        return self

There is no argument in save that allows me to set the nx flag and pass it downstream to the .set(...) call.

set does have an nx flag option, but the wrapper save method does not.

    def set(
        self,
        name: str,
        path: str,
        obj: JsonType,
        nx: Optional[bool] = False,
        xx: Optional[bool] = False,
        decode_keys: Optional[bool] = False,
    ) -> Optional[str]:

pramttl avatar Jun 19 '25 15:06 pramttl