Redis installation phpredis Jedis extension implementation and precautions, php, java, python related plug-in installation example code and document recommendations
1. Redis official website download: http://redis. io/download
Third-party download redis windows application,Supports 32-bit and 64-bit,Download according to actual situation
Download address: https ://github.com/dmajkic/redis/downloads
2. Copy the corresponding program to the directory you need ,I use 64-bit here& #xff0c;Put it in the E:\redis directory
3. Start the redis server:Open a cmd window,First switch to the directory where redis is placed(E:\redis) ,Run redis-server.exe redis.conf
Note that redis.conf is a configuration file,It mainly configures the port used by redis and other information(If not written, it will default to redis.conf& #xff09;
========== ======== 61;===========
version:redis64-2.8.2101
Start the service
C:\Users\zhengdunzhuang>d:
D:\>cd redis
redis-server.exe redis.conf (redis .windows.conf)
———————————-
Start another console set get
C:\Users \zhengdunzhuang>d:
D:\>cd redis
D:\redis>redis-cli.exe -h 127.0.0.1 -p 6379
127.0.0.1 :6379> set zdz zhengdz
OK
127.0.0.1:6379> get zdz
“zhengdz”
127.0.0.1:6379>
====&# 61;======== ======== 61;======
phpredis is a PHP module written in C language , used to connect and operate Redis data on the database.
$redis = new Redis();
http://www.oschina.net/p/phpredis
Download extension(php5.3.10 windows64 The bit is not good):https://github.com/phpredis/phpredis/downloads
phpredis windows64-bit version
wamp64-bit version Apache 2.2.21 Php 5.3.10 Because the project is useful I searched around for redis “You need to install the phpredis client” and “There is no 64-bit version” and you can only compile it yourself.
For your convenience, I directly upload the php5.3.10 version of php_redis.dll to the blog file:http://files.cnblogs.com/files/zdz8207/php_redis- wamp-php5.3.10.zip
After decompressing, place the dll in the ext directory of php, open php.ini, and add a line:
extension=php_redis.dll
D:\wamp\bin\php\php5.3.10\ext\php_redis.dll
D:\wamp\bin\apache\Apache2.2.21\bin\php.ini
Detection after restarting the service If the installation is successful, open phpinfo and search for reids to see if there is such content.
—– —————————————-
Online test Code:
<?php
/**
*
* Cache utilization test& #xff0c;Here we get the passed voting data ,increase it by 1 each time,If it increases to the set value,The number of votes
* will be written back to mysql,This greatly alleviates the problem The overhead of linking with mysql,The use of redis can be seen from this
*///Get the ID of the voting information
$aid = isset($_GET['aid']) ? ereg_replace(“[^0-9]”, “”, $_GET['aid']) : 0;//The number of current votes, refers to the data in redis
$this_click_num = 0 ;if($aid>2){
//Set the maximum number of votes written back,When this value is reached, write back to mysql
$update_till_num = 50;//Create redis object
$r = new Redis( );
$r->connect('127.0.0.1',6379);
//Get the number of data now
$this_click_num = $r->get( 'count_xin_newgame:'.$aid);
//Click count plus 1
$r->set('count_xin_newgame:'.$aid,$this_click_num&# 43;1);
if($this_click_num>=$update_till_num )
{
//If the number of clicks exceeds the set number,then write the data to mysql
if($this_click_num>$update_till_num)
require_once(dirname(__FILE__).”/db.php”);
//Update database
$db->ExecuteNoneQuery(
“UPDATE `addonnewgame`
SET `game_num` = game_num + '{$update_till_num}'
WHERE `dede_addonnewgame`.`aid` = ;{$aid};”
);
//Reset the number of votes to 0
$r->set('count_xin_newgame:'.$aid,0);
}
$r->setTimeout('count_xin_newgame:'.$aid,7*24*60*60 );
exit($this_click_num);
}
?>
=========&# 61;======== ======== 61;==
Jedis is the official preferred Java client development package for Redis.
Instance methods:
import redis.clients.jedis.*
Jedis jedis = new Jedis(“localhost”);
jedis.set(“foo “, “bar”);
String value = jedis.get(“foo”);
http://os.51cto.com/art/201403/431103.htm
http://www.oschina.net/p/jedis
For the convenience of everyone, I can directly upload the complete test project including the jar package to the blog file& #xff1a;http://files.cnblogs.com/files/zdz8207/jedisTest.zip
========= ;============& #61;======= ;==========
python3. 4 Study Notes (24) Python pycharm window installation redis MySQL-python related methods – Liufeng,Piaoran Wind-Blog Park
http://www.cnblogs.com/zdz8207/p/python_learn_note_24. html
==========&# 61;======== ======== 61;========
Redis is one of the more widely used NoSQL products. 一,The current stable version is 2.6.10,Including Github, Instagram, Blizzard, Sina Weibo, etc., all use Redis extensively in their products.
The code is open source based on the BSD protocol,The entire project has only more than 20,000 lines of code(Version 2.2),You can learn it in a relatively short time by reading the code The author’s design concept and Redis implementation method – know what it is and why it is.
Huang Jianhong (huangz) recently released the open source document “Redis Design and Implementation” – this is a collection of notes for learning Redis starting from reading the source code – for writing this The purpose of this document” says the author” Learn almost everything about Redis from data structure to server construction.
Redis Design and Implementation(First Edition) — Redis Design and Implementation
http://origin.redisbook.com/
p>
Redis practical experience and usage scenarios shared by three domestic and foreign giants in different fields-CSDN.NET
http://www.csdn.net/article/2013-10-07/2817107-three- giant-share-redis-experience
Redis cluster solution – LittlePeng – Blog Park
http://www.cnblogs.com/lulu/archive/2013/06/10/3130878.html