MCPcopy Create free account
hub / github.com/BIT-DataLab/LakeBench / RedisBuffer

Class RedisBuffer

join/LSH/datasketch/storage.py:881–907  ·  view source on GitHub ↗

A bufferized version of `redis.pipeline.Pipeline`. The only difference from the conventional pipeline object is the ``_buffer_size``. Once the buffer is longer than the buffer size, the pipeline is automatically executed, and the buffer cleared.

Source from the content-addressed store, hash-verified

879
880if redis is not None:
881 class RedisBuffer(redis.client.Pipeline):
882 '''A bufferized version of `redis.pipeline.Pipeline`.
883
884 The only difference from the conventional pipeline object is the
885 ``_buffer_size``. Once the buffer is longer than the buffer size,
886 the pipeline is automatically executed, and the buffer cleared.
887 '''
888
889 def __init__(self, connection_pool, response_callbacks, transaction, buffer_size,
890 shard_hint=None):
891 self._buffer_size = buffer_size
892 super(RedisBuffer, self).__init__(
893 connection_pool, response_callbacks, transaction,
894 shard_hint=shard_hint)
895
896 @property
897 def buffer_size(self):
898 return self._buffer_size
899
900 @buffer_size.setter
901 def buffer_size(self, value):
902 self._buffer_size = value
903
904 def execute_command(self, *args, **kwargs):
905 if len(self.command_stack) >= self._buffer_size:
906 self.execute()
907 super(RedisBuffer, self).execute_command(*args, **kwargs)
908
909
910 class RedisStorage:

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected