¡Esta es una revisión vieja del documento!
$ wget <desired redis version> $ tar xzf <file> $ cd <created folder> $ make
$ redis-server
$ redis-cli
Redis is not a database. If you need an analogy, think of it as a dict that runs on another computer.
Where in regular python dict you take things out and then modify them, in Redis you modify things inside and then you take them out. This helps if more than two Python applications talk to the same Redis.
In web development, you can use Redis as cache (key=url or post_id, value=html), as rate limiting backend (expiring entries, key=ip, value=count). In any Python project, you can use Redis as queue backend (Celery can use Redis), or to synchronize your non-essential state between Python instances.
ping, if everything is good, the server will respond pong.select, to select one of the 16 databases that Redis manage.$ pip install redis
import redis r = redis.StrictRedis(host='192.168.0.100', db=0, socket_timeout=2) r.set('foo', 'bar') print r.get('foo')
db argument.flushdb() will flush the database you are connected to (cleaning all the keys), while flushall() will clear all the keys in every database.ConnectionPool class). redis-py uses a connection pool to manage connections to a Redis server. By default, each Redis instance you create will in turn create its own connection pool. You can choose a concrete connection pool in the next way:pool = redis.ConnectionPool(host='localhost', port=6379, db=0) r = redis.Redis(connection_pool=pool)
keys() function of an StricRedis object. It also accept a pattern…r = redis.StrictRedis(host=YOUR_HOST, port=YOUR_PORT, db=YOUR_DB) r.keys() keys(pattern='*')
Redis object has the info() to obtain information about Redis server like