Skip to content

Define incr/decr as aliases of incrby/decrby #1874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 4 additions & 22 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,17 +1159,6 @@ def copy(self, source, destination, destination_db=None, replace=False):
params.append("REPLACE")
return self.execute_command("COPY", *params)

def decr(self, name, amount=1):
"""
Decrements the value of ``key`` by ``amount``. If no key exists,
the value will be initialized as 0 - ``amount``

For more information check https://redis.io/commands/decr
"""
# An alias for ``decr()``, because it is already implemented
# as DECRBY redis command.
return self.decrby(name, amount)

def decrby(self, name, amount=1):
"""
Decrements the value of ``key`` by ``amount``. If no key exists,
Expand All @@ -1179,6 +1168,8 @@ def decrby(self, name, amount=1):
"""
return self.execute_command("DECRBY", name, amount)

decr = decrby

def delete(self, *names):
"""
Delete one or more keys specified by ``names``
Expand Down Expand Up @@ -1350,26 +1341,17 @@ def getset(self, name, value):
"""
return self.execute_command("GETSET", name, value)

def incr(self, name, amount=1):
"""
Increments the value of ``key`` by ``amount``. If no key exists,
the value will be initialized as ``amount``

For more information check https://redis.io/commands/incr
"""
return self.incrby(name, amount)

def incrby(self, name, amount=1):
"""
Increments the value of ``key`` by ``amount``. If no key exists,
the value will be initialized as ``amount``

For more information check https://redis.io/commands/incrby
"""
# An alias for ``incr()``, because it is already implemented
# as INCRBY redis command.
return self.execute_command("INCRBY", name, amount)

incr = incrby

def incrbyfloat(self, name, amount=1.0):
"""
Increments the value at key ``name`` by floating ``amount``.
Expand Down