Skip to content

Commit

Permalink
Define incr/decr as aliases of incrby/decrby (#1874)
Browse files Browse the repository at this point in the history
  • Loading branch information
salty-horse committed Jan 16, 2022
1 parent 0affa0e commit d846f52
Showing 1 changed file with 4 additions and 22 deletions.
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

0 comments on commit d846f52

Please sign in to comment.