redis is installed under windows and used in PHP

WBOY
Release: 2016-08-08 09:25:25
Original
782 people have browsed it

1. Introduction to redis
redis is a key-value storage system. Similar to Memcached, it supports storage There are relatively more value types stored, including string (string), list (linked list), set (collection), zset (sorted set) --Ordered sets) and hashes (hash type). These data types all support push/pop, add/remove, intersection, union, difference, and richer operations, and these operations are It's atomic. On this basis, redis supports various different ways of sorting. Like memcached, data is cached in memory to ensure efficiency. The difference is that redis will periodically write updated data to disk or write modification operations to additional record files, and on this basis, master-slave (master-slave) synchronization is achieved.

Redis is a high-performance key-value database. The emergence of redis has largely compensated for the shortcomings of key/value storage such as memcached, and can play a very good supplementary role to relational databases in some situations. It provides Python, Ruby, Erlang, and PHP clients, which are very convenient to use.

2. Install redis under windows
Download address https://github.com/dmajkic/redis/downloads. The downloaded Redis supports 32bit and 64bit. Choose according to your actual situation, I choose 32bit. Copy the 32bit file contents to the directory that needs to be installed, such as: D:devredis-2.4.5.

Open a cmd window, use the cd command to switch to the specified directory (D:devredis-2.4.5) and run redis-server.exe redis.conf. After running, the following interface will appear.

This means that the Redis server has been installed successfully.

Reopen a cmd window, use the cd command to switch to the specified directory (D:devredis-2.4.5) and run redis-cli.exe -h 127.0.0.1 -p 6379, where 127.0.0.1 is the local ip and 6379 is the redis service The default port of the client. The successful operation is shown in the figure below.
In this way, the setup of Redis in windows environment has been completed. Isn’t it very simple?

In this way, the setup of Redis in windows environment has been completed. Isn’t it very simple?

The environment has been set up, it’s time to test it. For example: store a string with key test and value hello word, and then get the key value.

The hell word is output correctly and the test is successful!

3. Used in PHP

Download dll file

http://download.csdn.net/download/bluesky321/5355093

php_redis.dll extension For PHP5.4.x

PHP5.4.x redis extension php_redis.dll

Test platform: Windows XPx32 (FastCGI PHP5.4.9 Nginx 1.4.0)

Contains two versions: Non Thread Safe and Thread Safe

First put php_redis.dll and php_igbinary.dll into the PHP ext folder, and then add the following code to 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 in front of extension=php_redis.dll, otherwise this extension will not take effect

4. Used in PHP

The code is as follows

<?<span>php
    <span>$redis = <span>new<span> Redis();
    <span>$redis->connect('127.0.0.1',6379<span>);
    <span>$redis->set('test','hello redis'<span>);
    <span>echo <span>$redis->get('test'<span>);
?></span></span></span></span></span></span>
Copy after login

Output hello redis successful!

The above introduces the installation of redis under windows and its use in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!