Skip to content

.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 #703

Open
@pramttl

Description

@pramttl

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]:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions