Skip to content

Commit d846f52

Browse files
authored
Define incr/decr as aliases of incrby/decrby (#1874)
1 parent 0affa0e commit d846f52

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

redis/commands/core.py

+4-22
Original file line numberDiff line numberDiff line change
@@ -1159,17 +1159,6 @@ def copy(self, source, destination, destination_db=None, replace=False):
11591159
params.append("REPLACE")
11601160
return self.execute_command("COPY", *params)
11611161

1162-
def decr(self, name, amount=1):
1163-
"""
1164-
Decrements the value of ``key`` by ``amount``. If no key exists,
1165-
the value will be initialized as 0 - ``amount``
1166-
1167-
For more information check https://redis.io/commands/decr
1168-
"""
1169-
# An alias for ``decr()``, because it is already implemented
1170-
# as DECRBY redis command.
1171-
return self.decrby(name, amount)
1172-
11731162
def decrby(self, name, amount=1):
11741163
"""
11751164
Decrements the value of ``key`` by ``amount``. If no key exists,
@@ -1179,6 +1168,8 @@ def decrby(self, name, amount=1):
11791168
"""
11801169
return self.execute_command("DECRBY", name, amount)
11811170

1171+
decr = decrby
1172+
11821173
def delete(self, *names):
11831174
"""
11841175
Delete one or more keys specified by ``names``
@@ -1350,26 +1341,17 @@ def getset(self, name, value):
13501341
"""
13511342
return self.execute_command("GETSET", name, value)
13521343

1353-
def incr(self, name, amount=1):
1354-
"""
1355-
Increments the value of ``key`` by ``amount``. If no key exists,
1356-
the value will be initialized as ``amount``
1357-
1358-
For more information check https://redis.io/commands/incr
1359-
"""
1360-
return self.incrby(name, amount)
1361-
13621344
def incrby(self, name, amount=1):
13631345
"""
13641346
Increments the value of ``key`` by ``amount``. If no key exists,
13651347
the value will be initialized as ``amount``
13661348
13671349
For more information check https://redis.io/commands/incrby
13681350
"""
1369-
# An alias for ``incr()``, because it is already implemented
1370-
# as INCRBY redis command.
13711351
return self.execute_command("INCRBY", name, amount)
13721352

1353+
incr = incrby
1354+
13731355
def incrbyfloat(self, name, amount=1.0):
13741356
"""
13751357
Increments the value at key ``name`` by floating ``amount``.

0 commit comments

Comments
 (0)