Skip to content

Redis 3.2.0 compatible #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

extras_require = {
'test': tests_require,
'redis': ['redis>=2.8.0'],
'redis': ['redis>=3.2.0'],
'cassandra': ['cassandra-driver>=2.7.2'],
}

Expand Down
4 changes: 2 additions & 2 deletions stream_framework/storage/redis/structures/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from stream_framework.storage.redis.connection import get_redis_connection
from redis.client import BasePipeline
from redis.client import Pipeline


class RedisCache(object):
Expand Down Expand Up @@ -49,7 +49,7 @@ def _pipeline_if_needed(self, operation, *args, **kwargs):
If the redis connection is already in distributed state use it
Otherwise spawn a new distributed connection using .map
'''
pipe_needed = not isinstance(self.redis, BasePipeline)
pipe_needed = not isinstance(self.redis, Pipeline)
if pipe_needed:
pipe = self.redis.pipeline(transaction=False)
operation(pipe, *args, **kwargs)
Expand Down
3 changes: 2 additions & 1 deletion stream_framework/storage/redis/structures/sorted_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ def _add_many(redis, score_value_pairs):
score_value_chunks = chunks(score_value_list, 200)

for score_value_chunk in score_value_chunks:
result = redis.zadd(key, *score_value_chunk)
# redis >3.2 requires a dictionary
result = redis.zadd(key, {k:v for (v, k) in [score_value_chunk]})
logger.debug('adding to %s with score_value_chunk %s',
key, score_value_chunk)
results.append(result)
Expand Down
10 changes: 5 additions & 5 deletions stream_framework/tests/storage/redis/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ def test_zremrangebyrank(self):
key = 'test'
# start out fresh
redis.delete(key)
redis.zadd(key, 1, 'a')
redis.zadd(key, 2, 'b')
redis.zadd(key, 3, 'c')
redis.zadd(key, 4, 'd')
redis.zadd(key, 5, 'e')
redis.zadd(key, {1, 'a'})
redis.zadd(key, {2, 'b'})
redis.zadd(key, {3, 'c'})
redis.zadd(key, {4, 'd'})
redis.zadd(key, {5, 'e'})
expected_results = [('a', 1.0), ('b', 2.0), ('c', 3.0), (
'd', 4.0), ('e', 5.0)]
results = redis.zrange(key, 0, -1, withscores=True)
Expand Down