Home > Database > Mysql Tutorial > body text

​Installation and use of Redis

零下一度
Release: 2017-07-23 13:33:38
Original
1399 people have browsed it

                                                                                                                                                                                      Introduction to Redis

Already have Membercache and various databases, why did Redis come about? Redis is purely for applications. It is a high-performance key-value database. The emergence of redis has largely compensated for the shortcomings of keyvalue storage such as memcached and solved the situation of complete data loss after power outage; in some cases, it can play a very good supplementary role to the relational database. Performance test results show that SET operations can reach 110,000 times per second, and GET operations can reach 81,000 times per second (of course, different server configurations have different performance).

Redis is a distributed NoSQL database system for "key/value" pair type data. It is characterized by high performance, persistent storage, and adaptability. Highly concurrent application scenarios. Similar to Memcached, it supports relatively more stored value types, including string (string), list (linked list), set (set) and zset (ordered set). These data types support push/pop, add/remove, intersection union and difference, and richer operations, and these operations are atomic and support various different ways of sorting. Like redis and memcached, in order to ensure efficiency, data is cached in memory. 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 currently provides four data types: string, list, set and zset (sorted set).

The storage of Redis is divided into three parts: memory storage, disk storage and log file. There are three parameters in the configuration file to configure it.

  1. save seconds updates: Indicate how many update operations there are within a long period of time, and then synchronize the data to the data file.

  2. appendonly yes/no: Whether to log after each update operation. If not turned on, it may result in data loss for a period of time during a power outage. Because redis itself synchronizes data files according to the above save conditions, some data will only exist in memory for a period of time.

  3. appendfsync no/always/everysec: How the data cache is synchronized to disk. no means to wait for the operating system to synchronize the data cache to the disk, always means to manually call fsync() to write the data to the disk after each update operation, and everysec means to synchronize once per second.

#                                                                                                         Download redis online, I downloaded redis-2.0.2, I unzipped it to the same directory as where I installed Python, entered redis-2.0.2, there are these files below:

## redis-server.exe redis server daemon startup program redis.conf redis configuration file

redis -cli.exe redis command line operation tool. Of course, you can also use telnet to operate according to its plain text protocol redis-check-dump.exe Local database check

redis-check-aof.exe Update log check

redis-benchmark.exe Performance test, used to simulate sending M SETs/GETs queries by N clients at the same time (similar to Apache's ab tool)




benchmark tool test information:
Send 100,000 requests to the redis server, each request comes with 60 Concurrent clients

Oops, my computer was a little overwhelmed, but it finally showed that the test of 100,000 requests was completed in 4.03 seconds,

Some screenshots of the results are as follows:

Start the Redis service (conf file to set the configuration file (redis-server.exe redis.conf ), if not specified, the default is):

The startup cmd window should always be open. After closing, The Redis service is shut down.

At this time, the service is open. Open another cmd window to set up the client:

C:\redis-2.0.2> redis-cli.exe -h 127.0.0.1 -p 6379

Then we can enter the command we want to enter here. A very important operation of redis is set and get

The client is as follows:

At this time, the server side (here is also the local machine) displays as follows (with A client is connected):

The key set above on the client is resident in memory, which means closing the window , the value of get key will still be "jzhou" when you open the window next time, haha.

(Note that during operation, the server must enable the service, otherwise the client cannot connect.)

Redis provides multiple languages Clients, including Java, C++, python.

                                                                      

The above is the detailed content of ​Installation and use of Redis. For more information, please follow other related articles on the PHP Chinese website!

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