Skip to content

Commit

Permalink
Improve migration user-friendliness
Browse files Browse the repository at this point in the history
Signed-off-by: Salvatore Mesoraca <[email protected]>
  • Loading branch information
aiven-sal committed Jun 13, 2024
1 parent dcdbde3 commit 170b5d6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ b'bar'

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).

### Migration from redis-py

You are encouraged to use the new class names, but to allow for a smooth transition alias are available:

``` python
>>> import valkey as redis
>>> r = redis.Redis(host='localhost', port=6379, db=0)
>>> r.set('foo', 'bar')
True
>>> r.get('foo')
b'bar'
```

#### RESP3 Support
To enable support for RESP3, ensure you have at least version 5.0 of the client, and change your connection object to include *protocol=3*
Expand Down
25 changes: 18 additions & 7 deletions valkey/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ def int_or_str(value):
except AttributeError:
VERSION = tuple([99, 99, 99])


Redis = Valkey
StrictRedis = StrictValkey
RedisCluster = ValkeyCluster
RedisError = ValkeyError


__all__ = [
"AuthenticationError",
"AuthenticationWrongNumberOfArgsError",
Expand All @@ -71,24 +78,28 @@ def int_or_str(value):
"ConnectionPool",
"CredentialProvider",
"DataError",
"from_url",
"default_backoff",
"InvalidResponse",
"OutOfMemoryError",
"PubSubError",
"ReadOnlyError",
"Valkey",
"ValkeyCluster",
"ValkeyError",
"Redis",
"RedisCluster",
"RedisError",
"ResponseError",
"SSLConnection",
"Sentinel",
"SentinelConnectionPool",
"SentinelManagedConnection",
"SentinelManagedSSLConnection",
"SSLConnection",
"UsernamePasswordCredentialProvider",
"StrictRedis",
"StrictValkey",
"TimeoutError",
"UnixDomainSocketConnection",
"UsernamePasswordCredentialProvider",
"Valkey",
"ValkeyCluster",
"ValkeyError",
"WatchError",
"default_backoff",
"from_url",
]

0 comments on commit 170b5d6

Please sign in to comment.