Redis--Python operation connection Redis__python

Source: Internet
Author: User
Tags redis install redis redis server

1. Install Redis,pyredis First

sudo pip install Redis

sudo pip install Python-redis


2. Example:

Import Redis >>> r = Redis. Redis (host = ' localhost ', port = 6379, db = 0) >>> R. Set (' Guo ', ' Shuai ') True >>> R. Get (' Guo ') ' Shuai ' >>> R [' Guo '] ' Shuai ' >>> R. Keys () [' Guo '] >>> R. Dbsize () #当前数据库包含多少条数据 1L >>> R. Delete (' Guo ') 1 >>> R. Save () #执行 a checkpoint to write data back to disk. Blocking True >>> R while saving. Get (' Guo '); >>> R. Flushdb () #清空r中的所有数据 True


3. Pipeline:

Server and client is the use of socket to send TCP messages to communicate, using pipeline way from the client packaging multiple commands together, do not need to wait for a single command response to return, The Redis server, after processing more than one command, will package the processing results of multiple commands back to the client. This saves time wasting on network latency, pipeline way to pack and send commands,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.