diff options
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 65 |
1 files changed, 35 insertions, 30 deletions
@@ -18,12 +18,46 @@ From source: ## Getting Started >>> import redis - >>> r = redis.Redis(host='localhost', port=6379, db=0) + >>> r = redis.StrictRedis(host='localhost', port=6379, db=0) >>> r.set('foo', 'bar') True >>> r.get('foo') 'bar' +## API Reference + +The official Redis documentation does a great job of explaining each command in +detail (http://redis.io/commands). redis-py exposes two client classes that +implement these commands. The StrictRedis class attempts to adhere to the +official official command syntax. There are a few exceptions: + +* SELECT: Not implemented. See the explanation in the Thread Safety section + below. +* DEL: 'del' is a reserved keyword in the Python syntax. Therefore redis-py + uses 'delete' instead. +* CONFIG GET|SET: These are implemented separately as config_get or config_set. +* MULTI/EXEC: These are implemented as part of the Pipeline class. Calling + the pipeline method and specifying use_transaction=True will cause the + pipeline to be wrapped with the MULTI and EXEC statements when it is executed. + See more about Pipelines below. +* SUBSCRIBE/LISTEN: Similar to pipelines, PubSub is implemented as a separate + class as it places the underlying connection in a state where it can't + execute non-pubsub commands. Calling the pubsub method from the Redis client + will return a PubSub instance where you can subscribe to channels and listen + for messages. You can call PUBLISH from both classes. + +In addition to the changes above, the Redis class, a subclass of StrictRedis, +overrides several other commands to provide backwards compatibility with older +versions of redis-py: + +* LREM: Order of 'num' and 'value' arguments reversed such that 'num' can + provide a default value of zero. +* ZADD: Redis specifies the 'score' argument before 'value'. These were swapped + accidentally when being implemented and not discovered until after people + were already using it. The Redis class expects *args in the form of: + name1, score1, name2, score2, ... + + ## More Detail ### Connection Pools @@ -232,35 +266,6 @@ which is much easier to read: >>> r.transaction(client_side_incr, 'OUR-SEQUENCE-KEY') [True] - -## API Reference - -The official Redis documentation does a great job of explaining each command in -detail (http://redis.io/commands). In most cases, redis-py uses the same -arguments as the official spec. There are a few exceptions noted here: - -* SELECT: Not implemented. See the explanation in the Thread Safety section - above. -* ZADD: Redis specifies the 'score' argument before 'value'. These were swapped - accidentally when being implemented and not discovered until after people - were already using it. As of Redis 2.4, ZADD will start supporting variable - arguments. redis-py implements these as python keyword arguments where the - name is the 'value' and the value is the 'score'. -* DEL: 'del' is a reserved keyword in the Python syntax. Therefore redis-py - uses 'delete' instead. -* CONFIG GET|SET: These are implemented separately as config_get or config_set. -* MULTI/EXEC: These are implemented as part of the Pipeline class. Calling - the pipeline method and specifying use_transaction=True will cause the - pipeline to be wrapped with the MULTI and EXEC statements when it is executed. - See more about Pipelines above. -* SUBSCRIBE/LISTEN: Similar to pipelines, PubSub is implemented as a separate - class as it places the underlying connection in a state where it can't - execute non-pubsub commands. Calling the pubsub method from the Redis client - will return a PubSub instance where you can subscribe to channels and listen - for messages. You can call PUBLISH from both classes. -* LREM: Order of 'num' and 'value' arguments reversed such that 'num' can - provide a default value of zero. - ## Versioning scheme redis-py is versioned after Redis. For example, redis-py 2.0.0 should |