@@ -43,8 +43,8 @@ are managed.
43
43
44
44
ConnectionPools manage a set of Connection instances. redis-py ships with two
45
45
types of Connections. The default, Connection, is a normal TCP socket based
46
- connection. UnixDomainSocketConnection allows for clients running on the same
47
- device to connect via a unix domain socket. To use a
46
+ connection. The UnixDomainSocketConnection allows for clients running on the
47
+ same device as the server to connect via a unix domain socket. To use a
48
48
UnixDomainSocketConnection connection, simply pass the class to the
49
49
connection_class argument of either the Redis or ConnectionPool class. You must
50
50
also specify the path argument, which is a string to the unix domain socket
@@ -60,15 +60,16 @@ useful if you want to control the socket behavior within an async framework.
60
60
### Parsers
61
61
62
62
Parser classes provide a way to control how responses from the Redis server
63
- are parsed. redis-py ships with two parse classes, the PythonParse and the
63
+ are parsed. redis-py ships with two parser classes, the PythonParser and the
64
64
HiredisParser. By default, redis-py will attempt to use the HiredisParser if
65
65
you have the hiredis module installed and will fallback to the PythonParser
66
66
otherwise.
67
67
68
68
Hiredis is a C library maintained by the core Redis team. Pieter Noordhuis was
69
69
kind enough to create Python bindings. Using Hiredis can provide up to a
70
- 10x speed improvement. The performance increase is most noticeable when
71
- retrieving many pieces of data, such as from a ZRANGE or HGETALL operation.
70
+ 10x speed improvement in parsing responses from the Redis server. The
71
+ performance increase is most noticeable when retrieving many pieces of data,
72
+ such as from LRANGE or SMEMBERS operations.
72
73
73
74
Hiredis is available on Pypi, and can be installed via pip or easy_install
74
75
just like redis-py.
@@ -89,14 +90,14 @@ Custom callbacks can be added on a per-instance basis using the
89
90
set_response_callback method. This method accepts two arguments: a command
90
91
name and the callback. Callbacks added in this manner are only valid on the
91
92
instance the callback is added to. If you want to define or override a callback
92
- globally, then you should look into making a subclass and added your callback
93
- to the REDIS_CALLBACKS class dictionary.
93
+ globally, you should make a subclass of the Redis client and add your callback
94
+ to its REDIS_CALLBACKS class dictionary.
94
95
95
96
Response callbacks take at least one parameter: the response from the Redis
96
97
server. Keyword arguments may also be accepted in order to further control
97
- how to interpret the response. The keyword arguments are specified during the
98
+ how to interpret the response. These keyword arguments are specified during the
98
99
command's call to execute_command. The ZRANGE implementation demonstrates the
99
- use of response callback keyword arguments using the "withscores" argument.
100
+ use of response callback keyword arguments with its "withscores" argument.
100
101
101
102
## Thread Safety
102
103
@@ -106,19 +107,15 @@ command execution, and returned to the pool directly after. Command execution
106
107
never modifies state on the client instance.
107
108
108
109
However, there is one caveat: the Redis SELECT command. The SELECT command
109
- allows you to switch to a separate database on the same Redis server . That
110
- database remains selected until another is selected. This creates a proble in
111
- that connections could be returned to the pool that are now set to a different
112
- database.
110
+ allows you to switch the database currently in use by the connection . That
111
+ database remains selected until another is selected or until the connection is
112
+ closed. This creates an issue in that connections could be returned to the pool
113
+ that are connected to a different database.
113
114
114
115
As a result, redis-py does not implement the SELECT command on client instances.
115
- If you use multiple Redis databases, you should create a separate client
116
- instance (and possible a separate connection pool) to each database.
117
-
118
- ## Versioning scheme
119
-
120
- redis-py is versioned after Redis. So, for example, redis-py 2.0.0 should
121
- support all the commands available in Redis 2.0.0.
116
+ If you use multiple Redis databases within the same application, you should
117
+ create a separate client instance (and possibly a separate connection pool) for
118
+ each database.
122
119
123
120
## API Reference
124
121
@@ -131,20 +128,24 @@ arguments as the official spec. There are a few exceptions noted here:
131
128
* ZADD: Redis specifies the 'score' argument before 'value'. These were swapped
132
129
accidentally when being implemented and not discovered until after people
133
130
were already using it. As of Redis 2.4, ZADD will start supporting variable
134
- arguments. redis-py implements these as python keyword arguments, where the
131
+ arguments. redis-py implements these as python keyword arguments where the
135
132
name is the 'value' and the value is the 'score'.
136
133
* DEL: 'del' is a reserved keyword in the Python syntax. Therefore redis-py
137
134
uses 'delete' instead.
138
- * CONFIG GET|SET: These are implemented separately config_get or config_set.
135
+ * CONFIG GET|SET: These are implemented separately as config_get or config_set.
139
136
* MULTI/EXEC: These are implemented as part of the Pipeline class. Calling
140
137
the pipeline method and specifying use_transaction=True will cause the
141
- pipline to be wrapped with the MULTI and EXEC statements when it is executed.
138
+ pipeline to be wrapped with the MULTI and EXEC statements when it is executed.
142
139
* SUBSCRIBE/LISTEN: Similar to pipelines, PubSub is implemented as a separate
143
140
class as it places the underlying connection in a state where it can't
144
141
execute non-pubsub commands. Calling the pubsub method from the Redis client
145
142
will return a PubSub instance where you can subscribe to channels and listen
146
143
for messages. You can call PUBLISH from both classes.
147
144
145
+ ## Versioning scheme
146
+
147
+ redis-py is versioned after Redis. For example, redis-py 2.0.0 should
148
+ support all the commands available in Redis 2.0.0.
148
149
149
150
Author
150
151
------
0 commit comments