From d846f52cb581a20af731138ccaf14745464e7356 Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Sun, 16 Jan 2022 17:49:24 +0200 Subject: Define incr/decr as aliases of incrby/decrby (#1874) --- redis/commands/core.py | 26 ++++---------------------- 1 file 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``. -- cgit v1.2.1