summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Avtalion <ori@avtalion.name>2022-01-16 17:49:24 +0200
committerGitHub <noreply@github.com>2022-01-16 17:49:24 +0200
commitd846f52cb581a20af731138ccaf14745464e7356 (patch)
tree58d403d0e82f1b78e04a03df6092acd1b6078c6a
parent0affa0ed3f3cbcb6dec29b34a580f769f69ae9f7 (diff)
downloadredis-py-d846f52cb581a20af731138ccaf14745464e7356.tar.gz
Define incr/decr as aliases of incrby/decrby (#1874)
-rw-r--r--redis/commands/core.py26
1 files changed, 4 insertions, 22 deletions
diff --git a/redis/commands/core.py b/redis/commands/core.py
index 4f0accd..73003e7 100644
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -1159,17 +1159,6 @@ class BasicKeyCommands:
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,
@@ -1179,6 +1168,8 @@ class BasicKeyCommands:
"""
return self.execute_command("DECRBY", name, amount)
+ decr = decrby
+
def delete(self, *names):
"""
Delete one or more keys specified by ``names``
@@ -1350,15 +1341,6 @@ class BasicKeyCommands:
"""
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,
@@ -1366,10 +1348,10 @@ class BasicKeyCommands:
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``.