Home > Backend Development > PHP Tutorial > Install redis under windows and use it in PHP, redisphp_PHP tutorial

Install redis under windows and use it in PHP, redisphp_PHP tutorial

WBOY
Release: 2016-07-13 09:55:56
Original
996 people have browsed it

Redis is installed under Windows and used in PHP, redisphp

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
The download address is 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 default port of the redis server. The successful operation is shown in the figure below.
In this way, the establishment of Redis in windows environment has been completed. Isn’t it very simple?

In this way, the setup of Redis 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 correctly output and the test is successful!

3. Use 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 both Non Thread Safe and Thread Safe versions

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. Use 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></span></span></span></span></span>
Copy after login

Output hello redis successfully!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/990891.htmlTechArticleredis is installed under windows and used in PHP, redisphp 1. Introduction to redis redis is a key-value storage system. Similar to Memcached, it supports storing relatively more value types, including stri...
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