Familiar with the installation and use of redis and redis in Windows

Source: Internet
Author: User
Tags download redis redis server

About nosql

Before introducing redis, I 'd like to know nosql, that is, not only SQL, which is a non-relational data storage and key/value pair storage. Existing nosql dB products: redis/MongoDB/memcached/hbase/Cassandra/Tokyo Cabinet/Voldemort/dynomite/Riak/couchdb/hypertable/flare/TiN/lightcloud/kiokudb/scalaris/Kai/thrudb, and so on ~~~

Why do we need nosql non-relational databases?

  • High Performance-high concurrency read/write requirements for Databases
  • Huge storage-high-efficiency storage and access to massive data
  • High Scalability & High Availability-high scalability and high availability requirements for Databases

Redis Introduction

Why does redis have membercache and various databases? Redis is generated purely for applications. It is a high-performance Key-value database. The emergence of redis largely compensates for the shortage of keyValue storage such as memcached, and solves the situation that data is completely lost after power disconnection. In some cases, it can play a good complementary role for relational databases. The performance test results indicate that the set operation can be up to 110000 times per second, and the get operation can be performed 81000 times per second (of course, different server configurations have different performance ).

Redis is a distributed nosql Database System Oriented to "key/value" pairs of data types. It features high performance and persistent storage, and is suitable for high-concurrency application scenarios. Similar to memcached, memcached supports more storage value types, including string, list, set, and zset ). These data types support push/pop, Add/Remove, intersection union and difference set, and richer operations. These operations are atomic and support sorting in different ways. Redis is the same as memcached. To ensure efficiency, data is cached in the memory. 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 currently provides four data types: String, list, set, and zset (sorted set ).

Redis storage is divided into three parts: memory storage, disk storage, and log files. The configuration file contains three parameters for configuration.

  1. Save seconds updates: specifies the time in which an update operation is performed to synchronize data to a data file.
  2. Appendonly Yes/No: whether to record logs after each update operation. If it is not enabled, data may be lost for a period of time during power failure. Because redis synchronizes data files according to the above save conditions, some data will only exist in the memory for a period of time.
  3. Appendfsync no/always/everysec: The data cache is synchronized to the disk. "No" indicates that the data is cached and synchronized to the disk by the operating system. "Always" indicates that the data is written to the disk by manually calling fsync () after each update operation, and "everysec" indicates that the data is synchronized once per second.

Install and use redis in Windows

First download redis online, I downloaded a redis-2.0.2, I decompressed to the same directory as installing python, enter the redis-2.0.2, the following files:

Daemon boot program for redis-server.exe redis Server
Redis. conf redis configuration file
Redis-cli.exe redis command line tool. Of course, you can also use Telnet to operate based on its plain text protocol.
Redis-check-dump.exe local database check
Redis-check-aof.exe Update log check
Redis-benchmark.exe performance testing to simulate sending M sets/gets queries simultaneously by N clients (similar to Apache's AB tool)

Benchmark tool test information:

Sends 0.1 million requests to the redis server, each with 60 concurrent clients

My computer is a little overwhelmed, but it still shows that 4.03 requests were tested in 0.1 million seconds,

Some results are as follows:

Start redis Service(Conf file configuration file (redis-server.exe redis. conf), if not specified, the default value is ):

The cmd window must be open all the time. When it is closed, the redis service will be closed.

When the service is enabled, another cmd window is opened to set 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:

In this case, the server (which is also a local machine) is shown as follows (a client is connected ):

The key set on the client is resident memory, that is, the window is closed. The value of the get key in the next window is still "jzhou.

(During the operation, the server must enable the Service; otherwise, the client cannot be connected .)

Redis provides clients in multiple languages, including Java, C ++, and python.

Python operations on redis

If you want to use python to operate redis, You need to download a redis Python Development Kit redis-py (available on the Internet) and put it under the python installation directory, go to the redis-py directory and execute setup. PY (you need to download setuptools and then execute Python setup. PY install)

The installation takes a few seconds and enters the python environment. If you do anything, it indicates that redis has been imported successfully:

 

I quit CMD and want to import redis directly in Python IDE, but the import failed, prompting that this module does not exist. I thought, oh, I should add the path redis-py to the system environment variable so that python can recognize it. If so, I will "C: \ python27 \ redis-py ", after adding the system path and operating redis In the python ide again, you do not need to enter it in the CMD black box every time.

 

First understanding of redis Lesson 1. If any errors occur, please note.

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.