Redis is installed in Windows and used in PHP
1. redis Introduction
Redis is a key-value storage system. Similar to Memcached, Memcached supports more storage value types, including string, list, set, and zset) and hashs (hash type ). These data types support push/pop, add/remove, Intersection Set and difference set, and more abundant operations, and these operations are atomic. On this basis, redis supports sorting in different ways. Like memcached, data is cached in the memory to ensure efficiency. The difference is that redis periodically writes the updated data to the disk or writes the modification operation to the append record file, and on this basis implements master-slave (master-slave) synchronization.
Redis is a high-performance key-value database. The emergence of redis largely compensates for the shortage of key/value storage such as memcached. In some cases, it can play a good complementary role for relational databases. It provides Python, Ruby, Erlang, and PHP clients for ease of use.
2. Install redis in Windows
Https://github.com/dmajkic/redis/downloads. The downloaded Redis supports 32bit and 64bit. Select 32bit based on your actual situation. Copy the 32bit file content to the directory to be installed, such as: D: \ dev \ redis-2.4.5.
Open a cmd window and use the cd command to switch to the specified directory (D: \ dev \ redis-2.4.5) and run the redis-server.exe redis. conf. The following page is displayed after running.
This indicates that the Redis server has been installed successfully.
Reopen a cmd window and use the cd command to switch to the specified directory (D: \ dev \ redis-2.4.5) and run redis-cli.exe-h 127.0.0.1-p 6379, where 127.0.0.1 is a local ip, 6379 is the default port of the redis server. As shown in.
In this way, the setup in Redis windows environment is complete, isn't it easy.
In this way, the setup in Redis windows environment is complete, isn't it easy.
The environment has been set up. You have to test it. For example, store a string whose key is test and value is hello word, and then obtain the key value.
The hell word is output correctly. The test is successful!
3. Use in PHP
Download dll files
Http://download.csdn.net/download/bluesky321/5355093
Php_redis.dll extension For PHP5.4.x
Php_redis.dll extension for redis in PHP5.4.x
Test Platform: Windows XPx32 (FastCGI PHP5.4.9 Nginx 1.4.0)
Includes both Non-Thread Safe and Thread Safe versions.
First, put php_redis.dll and php_igbinary.dll into the ext folder of PHP, and then add the following code in the php. ini configuration file:
Extension = php_igbinary.dll
Extension = php_redis.dll
Restart the web Server
Note: extension = php_igbinary.dll must be placed before extension = php_redis.dll; otherwise, this extension will not take effect.
4. Use in PHP
The Code is as follows:
<? Php
$ Redis = new Redis ();
$ Redis-> connect ('2017. 0.0.1 ', 127 );
$ Redis-> set ('test', 'Hello redis ');
Echo $ redis-> get ('test ');
?>
Hello redis output!
Install and test Redis in Ubuntu 14.04
Redis cluster details
Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis
Redis series-installation, deployment, and maintenance
Install Redis in CentOS 6.3
Learning notes on Redis installation and deployment
Redis. conf
Redis details: click here
Redis: click here
This article permanently updates the link address: