Skip to content
Open
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
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# USAGE:
# docker build -t redisimp ./
# docker run --entrypoint redisimp redisimp -s ip1:6379 -d ip2:6379


FROM python AS build
RUN pip install --upgrade pip


COPY ./ ./

RUN pip install -r dev-requirements.txt

RUN python3 setup.py bdist_wheel


FROM python

RUN pip install --upgrade pip

COPY --from=build ./dist/redisimp-*-py3-none-any.whl ./

RUN pip install ./redisimp-*-py3-none-any.whl

RUN rm ./redisimp-*-py3-none-any.whl

ENTRYPOINT ["redisimp"]
2 changes: 1 addition & 1 deletion redisimp/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.0
0.4.0
18 changes: 7 additions & 11 deletions redisimp/api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import re

try:
import rediscluster
except ImportError:
rediscluster = None
import redis
from .rdbparser import parse_rdb
import fnmatch
from six import string_types
Expand Down Expand Up @@ -99,7 +95,7 @@ def normalize(v):


def _supports_replace(conn):
if rediscluster and isinstance(conn, rediscluster.RedisCluster):
if isinstance(conn, redis.RedisCluster):
return True
version = conn.info().get('redis_version')
if not version:
Expand Down Expand Up @@ -145,7 +141,7 @@ def _clobber_copy(src, dst, pattern=None):
yields the keys it processes as it goes.
:param pattern:
:param src: redis.StrictRedis
:param dst: redis.StrictRedis or rediscluster.RedisCluster
:param dst: redis.StrictRedis or redis.RedisCluster
:return: None
"""
read = _read_data_and_pttl
Expand All @@ -164,7 +160,7 @@ def _backfill_copy(src, dst, pattern=None):
yields the keys it processes as it goes.
WON'T OVERWRITE the key if it exists. It'll skip over it.
:param src: redis.StrictRedis
:param dst: redis.StrictRedis or rediscluster.RedisCluster
:param dst: redis.StrictRedis or redis.RedisCluster
:param pattern: str
:return: None
"""
Expand Down Expand Up @@ -228,7 +224,7 @@ def _rdb_clobber_copy(src, dst, pattern=None):
yields the keys it processes as it goes.
:param pattern:
:param src: redis.StrictRedis
:param dst: redis.StrictRedis or rediscluster.RedisCluster
:param dst: redis.StrictRedis or redis.RedisCluster
:return: None
"""
_restore = _get_restore_handler(dst)
Expand All @@ -249,7 +245,7 @@ def _rdb_dryrun_copy(src, pattern=None):
yields the keys it processes as it goes.
WON'T OVERWRITE the key if it exists. It'll skip over it.
:param src: redis.StrictRedis
:param dst: redis.StrictRedis or rediscluster.RedisCluster
:param dst: redis.StrictRedis or redis.RedisCluster
:param pattern: str
:return: None
"""
Expand All @@ -266,7 +262,7 @@ def _rdb_backfill_copy(src, dst, pattern=None):
yields the keys it processes as it goes.
WON'T OVERWRITE the key if it exists. It'll skip over it.
:param src: redis.StrictRedis
:param dst: redis.StrictRedis or rediscluster.RedisCluster
:param dst: redis.StrictRedis or redis.RedisCluster
:param pattern: str
:return: None
"""
Expand Down
22 changes: 10 additions & 12 deletions redisimp/cli.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
# std lib
import argparse
import logging
import sys
import time
import logging
from signal import signal, SIGTERM

# 3rd party
try:
import rediscluster
except ImportError:
rediscluster = None
import redis
import redislite
from redis.exceptions import BusyLoadingError
Expand Down Expand Up @@ -122,13 +118,15 @@ def resolve_destination(dststring):
if not conn.info('cluster').get('cluster_enabled', None):
return conn

if not rediscluster:
raise RuntimeError(
'cluster destination specified and redis-py-cluster not installed')

host, port = dststring.split(':')
return rediscluster.RedisCluster(
startup_nodes=[{'host': host, 'port': port}], max_connections=1000)
if dststring.startswith("redis://") or \
dststring.startswith("rediss://") or \
dststring.startswith("unix://"):
return redis.RedisCluster.from_url(
dststring, max_connections=1000)
else:
return redis.RedisCluster.from_url(
"redis://{dststring}".format(dststring=dststring),
max_connections=1000)


# pylint: disable=unused-argument
Expand Down
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
redislite>=5.0.165407
# @akretschmar: sticking with redis 3.x; bumping to 4.x created dependency conflicts; not worth fighting right now
redis>=3.5.3
redis-py-cluster>=2.1.0
psutil
redislite
redis
six
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def run(self):
'Environment :: Web Environment',
'Operating System :: POSIX'],
license='MIT',
install_requires=['redis>=2.10.2', 'redislite>=3.0.0', 'six'],
tests_require=['redislite>=3.0.271', 'redis-py-cluster>=1.3.0'],
install_requires=['redis>=4.3.4', 'redislite>=6.0.0', 'six'],
tests_require=[],
include_package_data=True,
long_description=readme,
entry_points={'console_scripts': ['redisimp = redisimp.cli:main']},
Expand Down
3 changes: 1 addition & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# 3rd party
import redis
import redislite
import rediscluster
import redislite.patch

# our package
Expand All @@ -27,7 +26,7 @@ def flush_redis_data(conn):
if conn is None:
return

if rediscluster and isinstance(conn, rediscluster.RedisCluster):
if isinstance(conn, redis.RedisCluster):
conns = [redis.StrictRedis(host=node['host'], port=node['port'])
for node in conn.connection_pool.nodes.nodes.values()
if node.get('server_type', None) == 'master']
Expand Down