Redis is installed in Windows and used in PHP

Source: Internet
Author: User
Tags redis windows redis server

Installing Redis under Windows

1. Introduction to Redis
Redis 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 HASHS (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 operation to the appended record file, and Master-slave (Master-Slave) synchronization is implemented on this basis.

Redis is a high-performance Key-value database. The emergence of Redis, to a large extent, compensates for the lack of memcached such key/value storage, in some cases can be a good complement to the relational database. It provides the python,ruby,erlang,php client, which is very convenient to use.

2. Installing Redis under Windows
Https://github.com/dmajkic/redis/downloads. Redis supports 32bit and 64bit to download. According to their actual situation choice, I choose 32bit. Copy the contents of the 32bit file to the directory that needs to be installed, for example: 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) to run Redis-server.exe redis.conf . The following interface appears after running.

This means that the Redis server has been successfully installed.

Reopen a CMD window, use the CD command to switch to the specified directory (D:\dev\redis-2.4.5) to run redis-cli.exe-h 127.0.0.1-p 6379, where 127.0.0.1 is the local IP, 6379 is the default port on the Redis server. The run succeeds as shown in.
In this way, it is not easy to build a Redis windows environment.

In this way, it is not easy to build a Redis windows environment.

The environment has been set up, always test it. For example: Store a string with key test,value as Hello Word and get the key value.

Correct output hell Word, test success!

3. Use in PHP

Download DLL files

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

Php_redis.dll Extension for php5.4.x

php5.4.x's Redis extension php_redis.dll

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

Contains two versions of 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 in the php.ini configuration file:

Extension=php_igbinary.dll

Extension=php_redis.dll

Restarting 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

<? PHP     $redis New Redis ();     $redis->connect (' 127.0.0.1 ', 6379);     $redis->set (' Test ', ' Hello Redis ');     Echo $redis->get (' Test ');? >

Output Hello Redis success!

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.