Redis is a key-value storage system. Similar to memcached, memcached supports more storage value types, including string, list, set, and zset ). 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 keyValue storage such as memcached, and can play a very good complementary role in relational databases. It provides python, Ruby, Erlang, and PHP clients for ease of use.
To use redis in PHP, first install redis. Then configure the extension in PHP.
1. Install redis.
First download the redis Installation File (download) and decompress it to disk D or another disk.
Then install the SDK through the doscommand line.
Copy this folder to other places, such as the D: \ redis directory. Open a cmd window and use the CD command to switch the directory to D: \ redis and run the redis-server.exe redis. if you want to facilitate the conf operation, you can add the redis path to the system's environment variables, saving you the trouble of losing the path. conf can be omitted. If it is omitted, the default value is enabled. The following page is displayed:
At this time, another cmd window, the original do not close, or you will not be able to access the server to switch to the redis directory to run the redis-cli.exe-H 127.0.0.1-P 6379:
At this time, the configuration has been completed.
After the configuration is complete, you must add the redis extension in PHP before using PHP flexibly.
Installing the redis extension of PHP in Windows is very simple. Download A. dll extension package and put it in the ext directory of PHP. Add a line of configuration in PHP. ini.
PHPCodeTest
$ Redis = new redis ();
$ Redis-> connect ('2017. 0.0.1 ', 127 );
$ Redis-> set ('test', 'Hello world! ');
Echo $ redis-> get ('test ');
Output Hello world!