Using Python to connect to Redis, you need to install Python and redis-py, and in CentOS as an example, introduce Redis-py's client environment setup.No. 0 Step: Prepare for workHuawei Cloud purchased 1 ECS (I chose CentOS 6.3), a distributed cache instance (DCS for
enthusiasts Distribution Center:
Http://blog.nosqlfan.com
Several misunderstandings of redis:
Http://blog.nosqlfan.com/html/868.html
References:
Http://shopscor.javaeye.com/blog/792817
2. Install redis-py
Run
Open the Python Interpreter:
>>> Import redis>>> R = redis.
Original article in this: https://www.cnblogs.com/cnkai/p/7642787.htmlThere is a personal modification and correctionConnecting to a databaseStrictredisFrom Redis import Strictredis#!/usr/bin/env python#Coding:utf-8 fromRedisImportStrictredis fromRedisImportConnectionPool#linking to a database by using the default mode of 1#Redis = Strictredis (host= ' localhost
Python redis-cli.py Python3 redis-cli Command-line administration toolDue to the recent test of redis unauthorized access vulnerability, found that the machine does not have Redis installed, can not run redis-cli, so he wrote a si
1. Installation
Redis-py is the Python interface to the Redis Key-value database, installed as follows, and we'll talk about Hiredis this library
Copy Code code as follows:
$ sudo pip install Redis
$ sudo pip install Hiredis
2. Getting Started
Copy Code code as follows:
>>> Imp
How to operate redis in python and redis in python
This article describes how to operate redis in python. Share it with you for your reference. The details are as follows:
#! /Usr/bin/python
Installing RedisInstalling Redis into the/opt/redis-2.8 directory
wget http://download.redis.io/releases/redis-2.8.1.tar.gz
Tar-zxfx redis-2.8.1.tar.gz
CD redis-2.8.1
Make make prefix=/opt/redis-2.8 install
Installing RedisInstalling Redis into the/opt/redis-2.8 directory
wget http://download.redis.io/releases/redis-2.8.1.tar.gz
Tar-zxfx redis-2.8.1.tar.gz
CD redis-2.8.1
Make make prefix=/opt/redis-2.8 install
Downloadcd/usr/local/src/wget http://download.redis.io/releases/redis-2.8.17.tar.gzExtractTAR-ZXVF redis-2.8.17.tar.gzInstall the compilation componentYum Install build-essentialSwitch to the redis-2.8.17 directory, compileMake(Output hint:it ' s a good idea-to-run ' make test ';) ) indicates successGo to Catalog/home/redis
the key of the current database into the given DB.
Redis PERSIST Command
When the key expires, key will persist.
Redis pttl Command
Returns the remaining expiration time of key in milliseconds.
Redis TTL Command
Returns the remaining lifetime (TTL, Time to live) for a given key, in seconds.
parameters ' num ' and ' value ' is exchanged for a bit, the CLI is lrem queuename 0 ' string '. Here's 0 o'clock all the meaning. But the Redis class, the control and the string swapped.· Zadd: The order of score and value was not carefully reversed when implemented, then someone used it, that's all.· The order of Setex:time and value is reversed.. Pool: Connection PoolingImportRedis R= Redis. Strictredis
Installation of 1.redis: http://www.runoob.com/redis/redis-install.html2. Test if you can log in remotelyUse the Windows Command window to enter the Redis installation directory and use the command to remotely connect Centos7 Redis:Redis-cli-h 192.168.1.112-p 6379Test if you can read the master
), and hash (hash type). These data types support Push/pop, Add/remove, and intersection-set and difference sets, and richer operations, and these operations are atomic. Based on this, Redis supports sorting in a variety of different ways. As with memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to disk or writes the modified operati
-3.0.6]# CP redis.conf/ usr/local/redis/etc/
Start the service side /usr/local/redis/bin/redis-server #后台启动加 Start the client /usr/local/redis/bin/redis-cli
Python Operation Redis In
Recently writing a script to check the size of a Redis key value in all of the game area service profiles on a single server was intended to solve this problem by using shell+awk+sed, but because Redis configuration information is in the form of PHP arrays. The shell script was not written in the moment, Ask someone to help write a Python script, but their
I. Introduction of RedisRedis is a key-value storage system. Similar to memcached, it supports storing more value types, including string (string), list (linked list), set (set), Zset (sorted set-ordered collection), and hash (hash type). These data types support Push/pop, Add/remove, and intersection-set and difference sets, and richer operations, and these operations are atomic. Based on this, Redis supports sorting in a variety of different ways. A
System Environment:
Os:oracle Linux Enterprise 5.6
redis:redis-2.6.8
python:python-2.7.3
Redis Python package version: Redis-2.7.2.tar
Prerequisites:
1. Ensure that the Redis has been successfully installed and properly configured, reference documentation
Master-Slave Copy Document:
http://blog.csdn.net/lichangzai/art
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.