summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Chen Wang <60190294+Andrew-Chen-Wang@users.noreply.github.com>2021-10-14 09:36:33 -0400
committerGitHub <noreply@github.com>2021-10-14 16:36:33 +0300
commit358c293e7772a44f114c78b5c5129ba1e972240f (patch)
tree0f0dea7abcdb0ba9e3df8c998c0ddda09d0d1868
parent3dc28e9bdeb745107d20a0be8a7ffc565a71da10 (diff)
downloadredis-py-358c293e7772a44f114c78b5c5129ba1e972240f.tar.gz
Remove unused BitFieldOperation in client.py (#1590)
-rwxr-xr-xredis/client.py97
1 files changed, 0 insertions, 97 deletions
diff --git a/redis/client.py b/redis/client.py
index cbdb13d..2e2a26a 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -1862,100 +1862,3 @@ class Script:
# Overwrite the sha just in case there was a discrepancy.
self.sha = client.script_load(self.script)
return client.evalsha(self.sha, len(keys), *args)
-
-
-class BitFieldOperation:
- """
- Command builder for BITFIELD commands.
- """
- def __init__(self, client, key, default_overflow=None):
- self.client = client
- self.key = key
- self._default_overflow = default_overflow
- self.reset()
-
- def reset(self):
- """
- Reset the state of the instance to when it was constructed
- """
- self.operations = []
- self._last_overflow = 'WRAP'
- self.overflow(self._default_overflow or self._last_overflow)
-
- def overflow(self, overflow):
- """
- Update the overflow algorithm of successive INCRBY operations
- :param overflow: Overflow algorithm, one of WRAP, SAT, FAIL. See the
- Redis docs for descriptions of these algorithmsself.
- :returns: a :py:class:`BitFieldOperation` instance.
- """
- overflow = overflow.upper()
- if overflow != self._last_overflow:
- self._last_overflow = overflow
- self.operations.append(('OVERFLOW', overflow))
- return self
-
- def incrby(self, fmt, offset, increment, overflow=None):
- """
- Increment a bitfield by a given amount.
- :param fmt: format-string for the bitfield being updated, e.g. 'u8'
- for an unsigned 8-bit integer.
- :param offset: offset (in number of bits). If prefixed with a
- '#', this is an offset multiplier, e.g. given the arguments
- fmt='u8', offset='#2', the offset will be 16.
- :param int increment: value to increment the bitfield by.
- :param str overflow: overflow algorithm. Defaults to WRAP, but other
- acceptable values are SAT and FAIL. See the Redis docs for
- descriptions of these algorithms.
- :returns: a :py:class:`BitFieldOperation` instance.
- """
- if overflow is not None:
- self.overflow(overflow)
-
- self.operations.append(('INCRBY', fmt, offset, increment))
- return self
-
- def get(self, fmt, offset):
- """
- Get the value of a given bitfield.
- :param fmt: format-string for the bitfield being read, e.g. 'u8' for
- an unsigned 8-bit integer.
- :param offset: offset (in number of bits). If prefixed with a
- '#', this is an offset multiplier, e.g. given the arguments
- fmt='u8', offset='#2', the offset will be 16.
- :returns: a :py:class:`BitFieldOperation` instance.
- """
- self.operations.append(('GET', fmt, offset))
- return self
-
- def set(self, fmt, offset, value):
- """
- Set the value of a given bitfield.
- :param fmt: format-string for the bitfield being read, e.g. 'u8' for
- an unsigned 8-bit integer.
- :param offset: offset (in number of bits). If prefixed with a
- '#', this is an offset multiplier, e.g. given the arguments
- fmt='u8', offset='#2', the offset will be 16.
- :param int value: value to set at the given position.
- :returns: a :py:class:`BitFieldOperation` instance.
- """
- self.operations.append(('SET', fmt, offset, value))
- return self
-
- @property
- def command(self):
- cmd = ['BITFIELD', self.key]
- for ops in self.operations:
- cmd.extend(ops)
- return cmd
-
- def execute(self):
- """
- Execute the operation(s) in a single BITFIELD command. The return value
- is a list of values corresponding to each operation. If the client
- used to create this instance was a pipeline, the list of values
- will be present within the pipeline's execute.
- """
- command = self.command
- self.reset()
- return self.client.execute_command(*command)