Skip to content

Commit 920be14

Browse files
authored
Merge pull request #17 from valkey-io/aiven-sal/migration
Improve migration user-friendliness
2 parents b030ab6 + 5cfb660 commit 920be14

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ b'bar'
4949

5050
The above code connects to localhost on port 6379, sets a value in Redis, and retrieves it. All responses are returned as bytes in Python, to receive decoded strings, set *decode_responses=True*. For this, and more connection options, see [these examples](https://valkey-py.readthedocs.io/en/stable/examples.html).
5151

52+
### Migration from redis-py
53+
54+
You are encouraged to use the new class names, but to allow for a smooth transition alias are available:
55+
56+
``` python
57+
>>> import valkey as redis
58+
>>> r = redis.Redis(host='localhost', port=6379, db=0)
59+
>>> r.set('foo', 'bar')
60+
True
61+
>>> r.get('foo')
62+
b'bar'
63+
```
5264

5365
#### RESP3 Support
5466
To enable support for RESP3 change your connection object to include *protocol=3*

valkey/__init__.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ def int_or_str(value):
6060
except AttributeError:
6161
VERSION = tuple([99, 99, 99])
6262

63+
64+
Redis = Valkey
65+
StrictRedis = StrictValkey
66+
RedisCluster = ValkeyCluster
67+
RedisError = ValkeyError
68+
69+
6370
__all__ = [
6471
"AuthenticationError",
6572
"AuthenticationWrongNumberOfArgsError",
@@ -71,24 +78,28 @@ def int_or_str(value):
7178
"ConnectionPool",
7279
"CredentialProvider",
7380
"DataError",
74-
"from_url",
75-
"default_backoff",
7681
"InvalidResponse",
7782
"OutOfMemoryError",
7883
"PubSubError",
7984
"ReadOnlyError",
80-
"Valkey",
81-
"ValkeyCluster",
82-
"ValkeyError",
85+
"Redis",
86+
"RedisCluster",
87+
"RedisError",
8388
"ResponseError",
89+
"SSLConnection",
8490
"Sentinel",
8591
"SentinelConnectionPool",
8692
"SentinelManagedConnection",
8793
"SentinelManagedSSLConnection",
88-
"SSLConnection",
89-
"UsernamePasswordCredentialProvider",
94+
"StrictRedis",
9095
"StrictValkey",
9196
"TimeoutError",
9297
"UnixDomainSocketConnection",
98+
"UsernamePasswordCredentialProvider",
99+
"Valkey",
100+
"ValkeyCluster",
101+
"ValkeyError",
93102
"WatchError",
103+
"default_backoff",
104+
"from_url",
94105
]

0 commit comments

Comments
 (0)