txredisapi 1.4.12__tar.gz → 1.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {txredisapi-1.4.12/txredisapi.egg-info → txredisapi-1.5.0}/PKG-INFO +15 -5
- {txredisapi-1.4.12 → txredisapi-1.5.0}/setup.py +3 -3
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_bitops.py +12 -14
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_connection_charset.py +3 -5
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_hash_ops.py +2 -4
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_multibulk.py +2 -4
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_number_conversions.py +1 -3
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_pipelining.py +2 -4
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_protocol.py +4 -6
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_scripting.py +0 -2
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_sentinel.py +2 -3
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_subscriber.py +0 -2
- {txredisapi-1.4.12 → txredisapi-1.5.0/txredisapi.egg-info}/PKG-INFO +15 -5
- txredisapi-1.5.0/txredisapi.egg-info/requires.txt +1 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/txredisapi.py +48 -50
- txredisapi-1.4.12/txredisapi.egg-info/requires.txt +0 -2
- {txredisapi-1.4.12 → txredisapi-1.5.0}/LICENSE +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/MANIFEST.in +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/README.md +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/setup.cfg +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/__init__.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/mixins.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_basics.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_blocking.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_cancel.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_connection.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_hyperloglog.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_implicit_pipelining.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_list_ops.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_operations.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_publish.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_scan.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_sets.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_sort.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_sortedsets.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_transactions.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_unix_connection.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/tests/test_watch.py +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/txredisapi.egg-info/SOURCES.txt +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/txredisapi.egg-info/dependency_links.txt +0 -0
- {txredisapi-1.4.12 → txredisapi-1.5.0}/txredisapi.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: txredisapi
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: non-blocking redis client for python
|
|
5
5
|
Home-page: http://github.com/IlyaSkriblovsky/txredisapi
|
|
6
6
|
Author: Alexandre Fiori
|
|
@@ -11,7 +11,6 @@ Classifier: Intended Audience :: Developers
|
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
13
|
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 2.7
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.5
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.6
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.7
|
|
@@ -20,10 +19,21 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
21
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
22
|
+
Requires-Python: >=3.5
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: twisted
|
|
26
|
-
|
|
25
|
+
Requires-Dist: twisted[tls]
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: description-content-type
|
|
31
|
+
Dynamic: home-page
|
|
32
|
+
Dynamic: license
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
Dynamic: requires-dist
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
Dynamic: summary
|
|
27
37
|
|
|
28
38
|
txredisapi
|
|
29
39
|
==========
|
|
@@ -23,9 +23,10 @@ long_description = (this_directory / "README.md").read_text()
|
|
|
23
23
|
|
|
24
24
|
setuptools.setup(
|
|
25
25
|
name="txredisapi",
|
|
26
|
-
version="1.
|
|
26
|
+
version="1.5.0",
|
|
27
27
|
py_modules=["txredisapi"],
|
|
28
|
-
install_requires=["twisted"
|
|
28
|
+
install_requires=["twisted[tls]"],
|
|
29
|
+
python_requires=">=3.5",
|
|
29
30
|
author="Alexandre Fiori",
|
|
30
31
|
author_email="fiorix@gmail.com",
|
|
31
32
|
url="http://github.com/IlyaSkriblovsky/txredisapi",
|
|
@@ -39,7 +40,6 @@ setuptools.setup(
|
|
|
39
40
|
'Operating System :: OS Independent',
|
|
40
41
|
'License :: OSI Approved :: Apache Software License',
|
|
41
42
|
'Programming Language :: Python',
|
|
42
|
-
'Programming Language :: Python :: 2.7',
|
|
43
43
|
'Programming Language :: Python :: 3.5',
|
|
44
44
|
'Programming Language :: Python :: 3.6',
|
|
45
45
|
'Programming Language :: Python :: 3.7',
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
-
import six
|
|
17
|
-
|
|
18
16
|
import sys
|
|
19
17
|
import operator
|
|
20
18
|
|
|
@@ -48,7 +46,7 @@ class TestBitOps(unittest.TestCase, Redis26CheckMixin):
|
|
|
48
46
|
@defer.inlineCallbacks
|
|
49
47
|
def test_getbit(self):
|
|
50
48
|
key = self._KEYS[0]
|
|
51
|
-
yield self.db.set(key,
|
|
49
|
+
yield self.db.set(key, b'\xaa')
|
|
52
50
|
l = [1, 0, 1, 0, 1, 0, 1, 0]
|
|
53
51
|
for x in range(8):
|
|
54
52
|
r = yield self.db.getbit(key, x)
|
|
@@ -86,30 +84,30 @@ class TestBitOps(unittest.TestCase, Redis26CheckMixin):
|
|
|
86
84
|
def test_bitop_not(self):
|
|
87
85
|
return self._test_bitop([operator.__not__, operator.not_,
|
|
88
86
|
'not', 'NOT', 'NoT'],
|
|
89
|
-
|
|
87
|
+
b'\x0f\x0f\x0f\x0f',
|
|
90
88
|
None,
|
|
91
|
-
|
|
89
|
+
b'\xf0\xf0\xf0\xf0')
|
|
92
90
|
|
|
93
91
|
def test_bitop_or(self):
|
|
94
92
|
return self._test_bitop([operator.__or__, operator.or_,
|
|
95
93
|
'or', 'OR', 'oR'],
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
b'\x0f\x0f\x0f\x0f',
|
|
95
|
+
b'\xf0\xf0\xf0\xf0',
|
|
96
|
+
b'\xff\xff\xff\xff')
|
|
99
97
|
|
|
100
98
|
def test_bitop_and(self):
|
|
101
99
|
return self._test_bitop([operator.__and__, operator.and_,
|
|
102
100
|
'and', 'AND', 'AnD'],
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
b'\x0f\x0f\x0f\x0f',
|
|
102
|
+
b'\xf0\xf0\xf0\xf0',
|
|
103
|
+
b'\x00\x00\x00\x00')
|
|
106
104
|
|
|
107
105
|
def test_bitop_xor(self):
|
|
108
106
|
return self._test_bitop([operator.__xor__, operator.xor,
|
|
109
107
|
'xor', 'XOR', 'XoR'],
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
108
|
+
b'\x9c\x9c\x9c\x9c',
|
|
109
|
+
b'\x6c\x6c\x6c\x6c',
|
|
110
|
+
b'\xf0\xf0\xf0\xf0')
|
|
113
111
|
|
|
114
112
|
def test_bitop_invalid(self):
|
|
115
113
|
self.assertFailure(self.db.bitop('test', 'test', 'test'),
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
-
import six
|
|
17
|
-
|
|
18
16
|
from twisted.internet import defer
|
|
19
17
|
from twisted.trial import unittest
|
|
20
18
|
|
|
@@ -25,7 +23,7 @@ from tests.mixins import REDIS_HOST, REDIS_PORT
|
|
|
25
23
|
|
|
26
24
|
class TestConnectionCharset(unittest.TestCase):
|
|
27
25
|
TEST_KEY = 'txredisapi:test_key'
|
|
28
|
-
TEST_VALUE_UNICODE =
|
|
26
|
+
TEST_VALUE_UNICODE = str('\u262d' * 3)
|
|
29
27
|
TEST_VALUE_BINARY = b'\x00\x01' * 3
|
|
30
28
|
|
|
31
29
|
@defer.inlineCallbacks
|
|
@@ -34,7 +32,7 @@ class TestConnectionCharset(unittest.TestCase):
|
|
|
34
32
|
|
|
35
33
|
yield db.set(self.TEST_KEY, self.TEST_VALUE_BINARY)
|
|
36
34
|
result = yield db.get(self.TEST_KEY)
|
|
37
|
-
self.assertTrue(type(result) ==
|
|
35
|
+
self.assertTrue(type(result) == bytes)
|
|
38
36
|
self.assertEqual(result, self.TEST_VALUE_BINARY)
|
|
39
37
|
|
|
40
38
|
yield db.delete(self.TEST_KEY)
|
|
@@ -47,7 +45,7 @@ class TestConnectionCharset(unittest.TestCase):
|
|
|
47
45
|
yield db.set(self.TEST_KEY, self.TEST_VALUE_UNICODE)
|
|
48
46
|
result = yield db.get(self.TEST_KEY)
|
|
49
47
|
self.assertEqual(result, self.TEST_VALUE_UNICODE)
|
|
50
|
-
self.assertTrue(type(result) ==
|
|
48
|
+
self.assertTrue(type(result) == str)
|
|
51
49
|
|
|
52
50
|
yield db.delete(self.TEST_KEY)
|
|
53
51
|
yield db.disconnect()
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
-
import six
|
|
17
|
-
|
|
18
16
|
from twisted.internet import defer
|
|
19
17
|
from twisted.trial import unittest
|
|
20
18
|
|
|
@@ -58,8 +56,8 @@ class TestRedisHashOperations(unittest.TestCase):
|
|
|
58
56
|
t_dict['key2'] = 'dos'
|
|
59
57
|
yield db.hmset("txredisapi:HKeysHVals", t_dict)
|
|
60
58
|
|
|
61
|
-
vs_u = [
|
|
62
|
-
ks_u = [
|
|
59
|
+
vs_u = [str(v) for v in t_dict.values()]
|
|
60
|
+
ks_u = [str(k) for k in t_dict.keys()]
|
|
63
61
|
k_res = yield db.hkeys("txredisapi:HKeysHVals")
|
|
64
62
|
v_res = yield db.hvals("txredisapi:HKeysHVals")
|
|
65
63
|
self.assertEqual(sorted(ks_u), sorted(k_res))
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
-
import six
|
|
17
|
-
|
|
18
16
|
import os
|
|
19
17
|
import base64
|
|
20
18
|
|
|
@@ -61,7 +59,7 @@ class LargeMultiBulk(unittest.TestCase):
|
|
|
61
59
|
@defer.inlineCallbacks
|
|
62
60
|
def test_bulk_numeric(self):
|
|
63
61
|
test_values = [
|
|
64
|
-
|
|
62
|
+
b'', b'.hello', b'+world', b'123test',
|
|
65
63
|
+1, 0.1, 0.01, -0.1, 0, -10]
|
|
66
64
|
for v in test_values:
|
|
67
65
|
yield self.db.set(self._KEY, v)
|
|
@@ -76,7 +74,7 @@ class LargeMultiBulk(unittest.TestCase):
|
|
|
76
74
|
if there's a '.' in the string.
|
|
77
75
|
This test is to ensure this behavior isn't broken in the future.
|
|
78
76
|
'''
|
|
79
|
-
values = [
|
|
77
|
+
values = [b'+inf', b'-inf', b'NaN']
|
|
80
78
|
for x in values:
|
|
81
79
|
yield self.db.set(self._KEY, x)
|
|
82
80
|
r = yield self.db.get(self._KEY)
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
-
import six
|
|
17
|
-
|
|
18
16
|
import txredisapi as redis
|
|
19
17
|
from twisted.internet import defer
|
|
20
18
|
from twisted.trial import unittest
|
|
@@ -58,7 +56,7 @@ class TestNumberConversions(unittest.TestCase):
|
|
|
58
56
|
expected = format(k, "f")
|
|
59
57
|
else:
|
|
60
58
|
expected = str(k)
|
|
61
|
-
self.assertIsInstance(result,
|
|
59
|
+
self.assertIsInstance(result, str)
|
|
62
60
|
self.assertEqual(result, expected)
|
|
63
61
|
|
|
64
62
|
@defer.inlineCallbacks
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
import sys
|
|
17
17
|
|
|
18
|
-
import six
|
|
19
|
-
|
|
20
18
|
from twisted.trial import unittest
|
|
21
19
|
from twisted.internet import defer
|
|
22
20
|
from twisted.python import log
|
|
@@ -71,8 +69,8 @@ class TestRedisConnections(unittest.TestCase):
|
|
|
71
69
|
|
|
72
70
|
# Make sure that all SET commands were sent in a single pipelined write.
|
|
73
71
|
write_history = pipeline.transport.write_history
|
|
74
|
-
lines_in_first_write = write_history[0].split(
|
|
75
|
-
sets_in_first_write = sum(1 for w in lines_in_first_write if
|
|
72
|
+
lines_in_first_write = write_history[0].split(b"\n")
|
|
73
|
+
sets_in_first_write = sum(1 for w in lines_in_first_write if b"SET" in w)
|
|
76
74
|
self.assertEqual(sets_in_first_write, 3)
|
|
77
75
|
|
|
78
76
|
@defer.inlineCallbacks
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
|
|
16
|
-
import six
|
|
17
|
-
|
|
18
16
|
import txredisapi as redis
|
|
19
17
|
|
|
20
18
|
from twisted.trial import unittest
|
|
@@ -36,7 +34,7 @@ class LineReceiverSubclass(redis.LineReceiver):
|
|
|
36
34
|
|
|
37
35
|
|
|
38
36
|
class TestLineReciever(unittest.TestCase):
|
|
39
|
-
S =
|
|
37
|
+
S = b'TEST'
|
|
40
38
|
|
|
41
39
|
def setUp(self):
|
|
42
40
|
self.proto = LineReceiverSubclass()
|
|
@@ -47,14 +45,14 @@ class TestLineReciever(unittest.TestCase):
|
|
|
47
45
|
|
|
48
46
|
def test_excess_line_length(self):
|
|
49
47
|
self.assertTrue(self.transport.connected)
|
|
50
|
-
self.proto.dataReceived(
|
|
48
|
+
self.proto.dataReceived(b'\x00' * (self.proto.MAX_LENGTH + 1))
|
|
51
49
|
self.assertFalse(self.transport.connected)
|
|
52
50
|
|
|
53
51
|
def test_excess_delimited_line(self):
|
|
54
52
|
self.assertTrue(self.transport.connected)
|
|
55
53
|
self.proto.dataReceived(self.S + self.proto.delimiter)
|
|
56
54
|
self.assertEqual(self.proto._rcvd_line, self.S.decode())
|
|
57
|
-
s = (
|
|
55
|
+
s = (b'\x00' * (self.proto.MAX_LENGTH + 1)) + self.proto.delimiter
|
|
58
56
|
self.proto._rcvd_line = None
|
|
59
57
|
self.proto.dataReceived(s)
|
|
60
58
|
self.assertFalse(self.transport.connected)
|
|
@@ -94,4 +92,4 @@ class TestBaseRedisProtocol(unittest.TestCase):
|
|
|
94
92
|
|
|
95
93
|
def test_build_ping(self):
|
|
96
94
|
s = self._protocol._build_command("PING")
|
|
97
|
-
self.assertEqual(s,
|
|
95
|
+
self.assertEqual(s, b'*1\r\n$4\r\nPING\r\n')
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import six
|
|
2
1
|
import sys
|
|
3
2
|
from twisted.internet import defer, reactor
|
|
4
3
|
from twisted.internet.protocol import Factory
|
|
@@ -23,12 +22,12 @@ class FakeRedisProtocol(BaseRedisProtocol):
|
|
|
23
22
|
parts.extend(cls._encode_value(x) for x in value)
|
|
24
23
|
return b''.join(parts)
|
|
25
24
|
|
|
26
|
-
if isinstance(value,
|
|
25
|
+
if isinstance(value, str):
|
|
27
26
|
binary = value.encode("utf-8")
|
|
28
27
|
elif isinstance(value, bytes):
|
|
29
28
|
binary = value
|
|
30
29
|
else:
|
|
31
|
-
binary =
|
|
30
|
+
binary = str(value).encode("utf-8")
|
|
32
31
|
return b''.join([b'$', str(len(binary)).encode('ascii'), b'\r\n', binary, b'\r\n'])
|
|
33
32
|
|
|
34
33
|
def send_reply(self, reply):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: txredisapi
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: non-blocking redis client for python
|
|
5
5
|
Home-page: http://github.com/IlyaSkriblovsky/txredisapi
|
|
6
6
|
Author: Alexandre Fiori
|
|
@@ -11,7 +11,6 @@ Classifier: Intended Audience :: Developers
|
|
|
11
11
|
Classifier: Operating System :: OS Independent
|
|
12
12
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
13
|
Classifier: Programming Language :: Python
|
|
14
|
-
Classifier: Programming Language :: Python :: 2.7
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.5
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.6
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.7
|
|
@@ -20,10 +19,21 @@ Classifier: Programming Language :: Python :: 3.9
|
|
|
20
19
|
Classifier: Programming Language :: Python :: 3.10
|
|
21
20
|
Classifier: Programming Language :: Python :: 3.11
|
|
22
21
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
22
|
+
Requires-Python: >=3.5
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: twisted
|
|
26
|
-
|
|
25
|
+
Requires-Dist: twisted[tls]
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: description-content-type
|
|
31
|
+
Dynamic: home-page
|
|
32
|
+
Dynamic: license
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
Dynamic: requires-dist
|
|
35
|
+
Dynamic: requires-python
|
|
36
|
+
Dynamic: summary
|
|
27
37
|
|
|
28
38
|
txredisapi
|
|
29
39
|
==========
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
twisted[tls]
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
# Sharding and Consistent Hashing implementation by Gleicon Moraes.
|
|
23
23
|
#
|
|
24
24
|
|
|
25
|
-
import six
|
|
26
|
-
|
|
27
25
|
import bisect
|
|
28
26
|
import collections
|
|
29
27
|
import functools
|
|
@@ -91,8 +89,8 @@ def list_or_args(command, keys, args):
|
|
|
91
89
|
oldapi = bool(args)
|
|
92
90
|
try:
|
|
93
91
|
iter(keys)
|
|
94
|
-
if isinstance(keys,
|
|
95
|
-
isinstance(keys,
|
|
92
|
+
if isinstance(keys, str) or \
|
|
93
|
+
isinstance(keys, bytes):
|
|
96
94
|
keys = [keys]
|
|
97
95
|
if not oldapi:
|
|
98
96
|
return keys
|
|
@@ -140,13 +138,13 @@ class MultiBulkStorage(object):
|
|
|
140
138
|
class LineReceiver(protocol.Protocol, basic._PauseableMixin):
|
|
141
139
|
callLater = reactor.callLater
|
|
142
140
|
line_mode = 1
|
|
143
|
-
__buffer =
|
|
144
|
-
delimiter =
|
|
141
|
+
__buffer = b''
|
|
142
|
+
delimiter = b'\r\n'
|
|
145
143
|
MAX_LENGTH = 16384
|
|
146
144
|
|
|
147
145
|
def clearLineBuffer(self):
|
|
148
146
|
b = self.__buffer
|
|
149
|
-
self.__buffer =
|
|
147
|
+
self.__buffer = b''
|
|
150
148
|
return b
|
|
151
149
|
|
|
152
150
|
def dataReceived(self, data, unpause=False):
|
|
@@ -165,14 +163,14 @@ class LineReceiver(protocol.Protocol, basic._PauseableMixin):
|
|
|
165
163
|
line, self.__buffer = self.__buffer.split(self.delimiter, 1)
|
|
166
164
|
except ValueError:
|
|
167
165
|
if len(self.__buffer) > self.MAX_LENGTH:
|
|
168
|
-
line, self.__buffer = self.__buffer,
|
|
166
|
+
line, self.__buffer = self.__buffer, b''
|
|
169
167
|
return self.lineLengthExceeded(line)
|
|
170
168
|
break
|
|
171
169
|
else:
|
|
172
170
|
linelength = len(line)
|
|
173
171
|
if linelength > self.MAX_LENGTH:
|
|
174
172
|
exceeded = line + self.__buffer
|
|
175
|
-
self.__buffer =
|
|
173
|
+
self.__buffer = b''
|
|
176
174
|
return self.lineLengthExceeded(exceeded)
|
|
177
175
|
if hasattr(line, 'decode'):
|
|
178
176
|
why = self.lineReceived(line.decode())
|
|
@@ -183,11 +181,11 @@ class LineReceiver(protocol.Protocol, basic._PauseableMixin):
|
|
|
183
181
|
else:
|
|
184
182
|
if not self.paused:
|
|
185
183
|
data = self.__buffer
|
|
186
|
-
self.__buffer =
|
|
184
|
+
self.__buffer = b''
|
|
187
185
|
if data:
|
|
188
186
|
return self.rawDataReceived(data)
|
|
189
187
|
|
|
190
|
-
def setLineMode(self, extra=
|
|
188
|
+
def setLineMode(self, extra=b''):
|
|
191
189
|
self.line_mode = 1
|
|
192
190
|
if extra:
|
|
193
191
|
self.pauseProducing()
|
|
@@ -203,7 +201,7 @@ class LineReceiver(protocol.Protocol, basic._PauseableMixin):
|
|
|
203
201
|
raise NotImplementedError
|
|
204
202
|
|
|
205
203
|
def sendLine(self, line):
|
|
206
|
-
if isinstance(line,
|
|
204
|
+
if isinstance(line, str):
|
|
207
205
|
line = line.encode()
|
|
208
206
|
return self.transport.write(line + self.delimiter)
|
|
209
207
|
|
|
@@ -449,7 +447,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
449
447
|
|
|
450
448
|
def tryConvertData(self, data):
|
|
451
449
|
# The hiredis reader implicitly returns integers
|
|
452
|
-
if isinstance(data,
|
|
450
|
+
if isinstance(data, int):
|
|
453
451
|
return data
|
|
454
452
|
if isinstance(data, list):
|
|
455
453
|
return [self.tryConvertData(x) for x in data]
|
|
@@ -458,7 +456,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
458
456
|
if data:
|
|
459
457
|
num_data = data
|
|
460
458
|
try:
|
|
461
|
-
if isinstance(data,
|
|
459
|
+
if isinstance(data, bytes):
|
|
462
460
|
num_data = data.decode()
|
|
463
461
|
except UnicodeError:
|
|
464
462
|
pass
|
|
@@ -537,9 +535,9 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
537
535
|
return r
|
|
538
536
|
|
|
539
537
|
def _encode_value(self, arg):
|
|
540
|
-
if isinstance(arg,
|
|
538
|
+
if isinstance(arg, bytes):
|
|
541
539
|
return arg
|
|
542
|
-
elif isinstance(arg,
|
|
540
|
+
elif isinstance(arg, str):
|
|
543
541
|
if self.charset is None:
|
|
544
542
|
try:
|
|
545
543
|
return arg.encode()
|
|
@@ -565,15 +563,15 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
565
563
|
cmd_count = 0
|
|
566
564
|
for s in args:
|
|
567
565
|
cmd = self._encode_value(s)
|
|
568
|
-
cmds.extend(
|
|
566
|
+
cmds.extend(b"$")
|
|
569
567
|
for token in self._encode_value(len(cmd)), cmd:
|
|
570
568
|
cmds.extend(token)
|
|
571
|
-
cmds.extend(
|
|
569
|
+
cmds.extend(b"\r\n")
|
|
572
570
|
cmd_count += 1
|
|
573
571
|
|
|
574
|
-
command = bytes(
|
|
575
|
-
[
|
|
576
|
-
if not isinstance(command,
|
|
572
|
+
command = bytes(b"".join(
|
|
573
|
+
[b"*", self._encode_value(cmd_count), b"\r\n"]) + cmds)
|
|
574
|
+
if not isinstance(command, bytes):
|
|
577
575
|
command = command.encode()
|
|
578
576
|
return command
|
|
579
577
|
|
|
@@ -861,7 +859,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
861
859
|
Set the respective keys to the respective values.
|
|
862
860
|
"""
|
|
863
861
|
items = []
|
|
864
|
-
for pair in
|
|
862
|
+
for pair in mapping.items():
|
|
865
863
|
items.extend(pair)
|
|
866
864
|
return self.execute_command("MSET", *items)
|
|
867
865
|
|
|
@@ -871,7 +869,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
871
869
|
operation if none of the keys already exist
|
|
872
870
|
"""
|
|
873
871
|
items = []
|
|
874
|
-
for pair in
|
|
872
|
+
for pair in mapping.items():
|
|
875
873
|
items.extend(pair)
|
|
876
874
|
return self.execute_command("MSETNX", *items)
|
|
877
875
|
|
|
@@ -883,7 +881,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
883
881
|
srclen = len(srckeys)
|
|
884
882
|
if srclen == 0:
|
|
885
883
|
return defer.fail(RedisError("no ``srckeys`` specified"))
|
|
886
|
-
if isinstance(operation,
|
|
884
|
+
if isinstance(operation, str):
|
|
887
885
|
operation = operation.upper()
|
|
888
886
|
elif operation is operator.and_ or operation is operator.__and__:
|
|
889
887
|
operation = 'AND'
|
|
@@ -1034,7 +1032,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1034
1032
|
"""
|
|
1035
1033
|
Blocking LPOP
|
|
1036
1034
|
"""
|
|
1037
|
-
if isinstance(keys,
|
|
1035
|
+
if isinstance(keys, str):
|
|
1038
1036
|
keys = [keys]
|
|
1039
1037
|
else:
|
|
1040
1038
|
keys = list(keys)
|
|
@@ -1047,7 +1045,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1047
1045
|
"""
|
|
1048
1046
|
Blocking RPOP
|
|
1049
1047
|
"""
|
|
1050
|
-
if isinstance(keys,
|
|
1048
|
+
if isinstance(keys, str):
|
|
1051
1049
|
keys = [keys]
|
|
1052
1050
|
else:
|
|
1053
1051
|
keys = list(keys)
|
|
@@ -1215,7 +1213,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1215
1213
|
|
|
1216
1214
|
@staticmethod
|
|
1217
1215
|
def _handle_zincrby(data):
|
|
1218
|
-
if isinstance(data, (
|
|
1216
|
+
if isinstance(data, (bytes, str)):
|
|
1219
1217
|
return float(data)
|
|
1220
1218
|
return data
|
|
1221
1219
|
|
|
@@ -1330,7 +1328,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1330
1328
|
|
|
1331
1329
|
@staticmethod
|
|
1332
1330
|
def _handle_zscore(data):
|
|
1333
|
-
if isinstance(data, (
|
|
1331
|
+
if isinstance(data, (bytes, str)):
|
|
1334
1332
|
return int(data)
|
|
1335
1333
|
return data
|
|
1336
1334
|
|
|
@@ -1391,7 +1389,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1391
1389
|
aggregate = 'SUM'
|
|
1392
1390
|
else:
|
|
1393
1391
|
err_flag = True
|
|
1394
|
-
if isinstance(aggregate,
|
|
1392
|
+
if isinstance(aggregate, str):
|
|
1395
1393
|
aggregate_u = aggregate.upper()
|
|
1396
1394
|
if aggregate_u in ('MIN', 'MAX', 'SUM'):
|
|
1397
1395
|
aggregate = aggregate_u
|
|
@@ -1437,7 +1435,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1437
1435
|
Set the hash fields to their respective values.
|
|
1438
1436
|
"""
|
|
1439
1437
|
items = []
|
|
1440
|
-
for pair in
|
|
1438
|
+
for pair in mapping.items():
|
|
1441
1439
|
items.extend(pair)
|
|
1442
1440
|
return self.execute_command("HMSET", key, *items)
|
|
1443
1441
|
|
|
@@ -1463,7 +1461,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1463
1461
|
"""
|
|
1464
1462
|
Remove the specified field or fields from a hash
|
|
1465
1463
|
"""
|
|
1466
|
-
if isinstance(fields,
|
|
1464
|
+
if isinstance(fields, str):
|
|
1467
1465
|
fields = [fields]
|
|
1468
1466
|
else:
|
|
1469
1467
|
fields = list(fields)
|
|
@@ -1541,7 +1539,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1541
1539
|
self.inMulti = False
|
|
1542
1540
|
self.unwatch_cc = self._clear_txstate
|
|
1543
1541
|
self.commit_cc = lambda: ()
|
|
1544
|
-
if isinstance(keys,
|
|
1542
|
+
if isinstance(keys, str):
|
|
1545
1543
|
keys = [keys]
|
|
1546
1544
|
d = self.execute_command("WATCH", *keys).addCallback(self._tx_started)
|
|
1547
1545
|
return d
|
|
@@ -1619,7 +1617,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1619
1617
|
|
|
1620
1618
|
# Flush all the commands at once to redis. Wait for all replies
|
|
1621
1619
|
# to come back using a deferred list.
|
|
1622
|
-
self.transport.write(
|
|
1620
|
+
self.transport.write(b"".join(self.pipelined_commands))
|
|
1623
1621
|
|
|
1624
1622
|
d = defer.DeferredList(
|
|
1625
1623
|
deferredList=self.pipelined_replies,
|
|
@@ -1684,7 +1682,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1684
1682
|
return self.execute_command("BGREWRITEAOF")
|
|
1685
1683
|
|
|
1686
1684
|
def _process_info(self, r):
|
|
1687
|
-
if isinstance(r,
|
|
1685
|
+
if isinstance(r, bytes):
|
|
1688
1686
|
r = r.decode()
|
|
1689
1687
|
keypairs = [x for x in r.split('\r\n') if
|
|
1690
1688
|
':' in x and not x.startswith('#')]
|
|
@@ -1726,7 +1724,7 @@ class BaseRedisProtocol(LineReceiver):
|
|
|
1726
1724
|
return err
|
|
1727
1725
|
|
|
1728
1726
|
def eval(self, script, keys=[], args=[]):
|
|
1729
|
-
if isinstance(script,
|
|
1727
|
+
if isinstance(script, str):
|
|
1730
1728
|
script = script.encode()
|
|
1731
1729
|
h = hashlib.sha1(script).hexdigest()
|
|
1732
1730
|
if h in self.script_hashes:
|
|
@@ -1853,7 +1851,7 @@ class HiredisProtocol(BaseRedisProtocol):
|
|
|
1853
1851
|
self._reader.feed(data)
|
|
1854
1852
|
res = self._reader.gets()
|
|
1855
1853
|
while res is not False:
|
|
1856
|
-
if isinstance(res, (
|
|
1854
|
+
if isinstance(res, (str, bytes, list)):
|
|
1857
1855
|
res = self.tryConvertData(res)
|
|
1858
1856
|
if res == "QUEUED":
|
|
1859
1857
|
self.transactions += 1
|
|
@@ -1868,8 +1866,8 @@ class HiredisProtocol(BaseRedisProtocol):
|
|
|
1868
1866
|
return [self._convert_bin_values(x) for x in result]
|
|
1869
1867
|
elif isinstance(result, dict):
|
|
1870
1868
|
return dict((self._convert_bin_values(k), self._convert_bin_values(v))
|
|
1871
|
-
for k, v in
|
|
1872
|
-
elif isinstance(result,
|
|
1869
|
+
for k, v in result.items())
|
|
1870
|
+
elif isinstance(result, bytes):
|
|
1873
1871
|
return self.tryConvertData(result)
|
|
1874
1872
|
return result
|
|
1875
1873
|
|
|
@@ -1934,22 +1932,22 @@ class SubscriberProtocol(RedisProtocol):
|
|
|
1934
1932
|
self.replyQueue.put(reply)
|
|
1935
1933
|
|
|
1936
1934
|
def subscribe(self, channels):
|
|
1937
|
-
if isinstance(channels,
|
|
1935
|
+
if isinstance(channels, str):
|
|
1938
1936
|
channels = [channels]
|
|
1939
1937
|
return self.execute_command("SUBSCRIBE", *channels, apply_timeout=False)
|
|
1940
1938
|
|
|
1941
1939
|
def unsubscribe(self, channels):
|
|
1942
|
-
if isinstance(channels,
|
|
1940
|
+
if isinstance(channels, str):
|
|
1943
1941
|
channels = [channels]
|
|
1944
1942
|
return self.execute_command("UNSUBSCRIBE", *channels)
|
|
1945
1943
|
|
|
1946
1944
|
def psubscribe(self, patterns):
|
|
1947
|
-
if isinstance(patterns,
|
|
1945
|
+
if isinstance(patterns, str):
|
|
1948
1946
|
patterns = [patterns]
|
|
1949
1947
|
return self.execute_command("PSUBSCRIBE", *patterns, apply_timeout=False)
|
|
1950
1948
|
|
|
1951
1949
|
def punsubscribe(self, patterns):
|
|
1952
|
-
if isinstance(patterns,
|
|
1950
|
+
if isinstance(patterns, str):
|
|
1953
1951
|
patterns = [patterns]
|
|
1954
1952
|
return self.execute_command("PUNSUBSCRIBE", *patterns)
|
|
1955
1953
|
|
|
@@ -2093,9 +2091,9 @@ class HashRing(object):
|
|
|
2093
2091
|
self.nodes.append(node)
|
|
2094
2092
|
for x in range(self.replicas):
|
|
2095
2093
|
uuid = node._factory.uuid
|
|
2096
|
-
if isinstance(uuid,
|
|
2094
|
+
if isinstance(uuid, str):
|
|
2097
2095
|
uuid = uuid.encode()
|
|
2098
|
-
crckey = zlib.crc32(
|
|
2096
|
+
crckey = zlib.crc32(b":".join(
|
|
2099
2097
|
[uuid, str(x).format().encode()]))
|
|
2100
2098
|
self.ring[crckey] = node
|
|
2101
2099
|
self.sorted_keys.append(crckey)
|
|
@@ -2105,7 +2103,7 @@ class HashRing(object):
|
|
|
2105
2103
|
def remove_node(self, node):
|
|
2106
2104
|
self.nodes.remove(node)
|
|
2107
2105
|
for x in range(self.replicas):
|
|
2108
|
-
crckey = zlib.crc32(
|
|
2106
|
+
crckey = zlib.crc32(b":".join(
|
|
2109
2107
|
[node, str(x).format().encode()]))
|
|
2110
2108
|
self.ring.remove(crckey)
|
|
2111
2109
|
self.sorted_keys.remove(crckey)
|
|
@@ -2160,7 +2158,7 @@ class ShardedConnectionHandler(object):
|
|
|
2160
2158
|
def _wrap(self, method, *args, **kwargs):
|
|
2161
2159
|
try:
|
|
2162
2160
|
key = args[0]
|
|
2163
|
-
assert isinstance(key,
|
|
2161
|
+
assert isinstance(key, str)
|
|
2164
2162
|
except:
|
|
2165
2163
|
raise ValueError(
|
|
2166
2164
|
"Method '%s' requires a key as the first argument" % method)
|
|
@@ -2195,7 +2193,7 @@ class ShardedConnectionHandler(object):
|
|
|
2195
2193
|
group[node].append(k)
|
|
2196
2194
|
|
|
2197
2195
|
deferreds = []
|
|
2198
|
-
for node, keys in
|
|
2196
|
+
for node, keys in group.items.items():
|
|
2199
2197
|
nd = node.mget(keys)
|
|
2200
2198
|
deferreds.append(nd)
|
|
2201
2199
|
|
|
@@ -2215,7 +2213,7 @@ class ShardedConnectionHandler(object):
|
|
|
2215
2213
|
except:
|
|
2216
2214
|
pass
|
|
2217
2215
|
else:
|
|
2218
|
-
nodes.append(
|
|
2216
|
+
nodes.append(b"%s:%s/%d" %
|
|
2219
2217
|
(cli.host, cli.port, conn._factory.size))
|
|
2220
2218
|
return "<Redis Sharded Connection: %s>" % ", ".join(nodes)
|
|
2221
2219
|
|
|
@@ -2229,7 +2227,7 @@ class ShardedUnixConnectionHandler(ShardedConnectionHandler):
|
|
|
2229
2227
|
except:
|
|
2230
2228
|
pass
|
|
2231
2229
|
else:
|
|
2232
|
-
nodes.append(
|
|
2230
|
+
nodes.append(b"%s/%d" %
|
|
2233
2231
|
(cli.name, conn._factory.size))
|
|
2234
2232
|
return "<Redis Sharded Connection: %s>" % ", ".join(nodes)
|
|
2235
2233
|
|
|
@@ -2825,4 +2823,4 @@ __all__ = [
|
|
|
2825
2823
|
]
|
|
2826
2824
|
|
|
2827
2825
|
__author__ = "Alexandre Fiori"
|
|
2828
|
-
__version__ = version = "1.
|
|
2826
|
+
__version__ = version = "1.5.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|