Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Redis Essentials

You're reading from   Redis Essentials Harness the power of Redis to integrate and manage your projects efficiently

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher Packt
ISBN-13 9781784392451
Length 230 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Python

There are many Redis client libraries for the Python language, and we are going to present redis-py, the most mature Redis client implementation for Python. The Python version used for all examples is 2.7.

Installing redis-py (it is recommended to install it in a virtualenv):

$ pip install redis

In this section, the Python code has comments that represent the result of the previous expression. It is recommended to run all of the code from this section in the interactive Python interpreter (python or ipython in the command line).

The basic commands in Python

Most Redis commands are accessed in redis-py through a very simple interface. Each executed command returns a value synchronously. Some basic commands are shown in the following code, and after this, you should be able to figure out how most of them work:

import redis
client = redis.StrictRedis(host='localhost', port=6379)

client.set("string:my_key", "Hello World")
client.get("string:my_key"...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image