Introduction to NoSQL and Redis and Redis installation and usage tutorials under Windows _redis

Source: Internet
Author: User
Tags benchmark download redis memcached redis redis server in python

NoSQL Introduction

Before introducing Redis, I would like to first recognize the next NoSQL, that is not just SQL, is a kind of non relational data storage, Key/value 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, wait ~ ~

Why do I need to nosql a non-relational database?

1.High performance-high concurrent read and write requirements for databases
2.Huge Storage-The need for efficient storage and access to massive data
3.High Scalability && High availability-scalability and high availability requirements for databases

Redis Introduction

There are already membercache and a variety of databases, Redis why is it produced? Redis is produced purely for application and is a high-performance key-value database. The emergence of Redis, to a large extent, compensates for the shortage of such keyvalue storage in memcached, solves the situation that the data is completely lost after power outage, and can complement the relational database in some occasions. Performance test results indicate that set operations can reach up to 110,000 times per second and get operations 81,000 times per second (of course, different server configuration performance is different).

Redis is a kind of "key/value" type data distributed NoSQL database system, characterized by high-performance, persistent storage, to adapt to high concurrent application scenarios. Like memcached, it supports a relatively larger number of stored value types, including string (string), list (linked list), set (set), and Zset (ordered set). These data types support Push/pop, Add/remove and intersection-set and differential sets and richer operations, and these operations are atomic and support sorting in various ways. Redis As with memcached, data is cached in memory to ensure efficiency. The difference is that Redis periodically writes the updated data to the disk or writes the modification operation to the appended record file, and on this basis, it realizes the Master-slave (master-slave) synchronization.

Redis currently offers four types of data: String,list,set and Zset (sorted set).

The Redis storage is divided into three parts: memory storage, disk storage and log files, and three parameters are configured in the configuration file.

1.save seconds Updates: Indicates how many times the update operation is synchronized to the data file for how long.
2.appendonly yes/no: Log records after each update operation. If it is not turned on, it may result in loss of data over time during a power outage. Because the 3.redis itself synchronizes data files according to the save condition above, some data will only exist in memory for a period of time.
Appendfsync no/always/everysec: How the data cache synchronizes to disk. No means that the operating system synchronizes the data cache to disk, and always indicates that Fsync () is manually invoked after each update operation to write the data to disk, EVERYSEC is synchronized once per second.

Installation and use of Redis under Windows

First on the Internet to download Redis, I downloaded the redis-2.0.2 (http://download.csdn.net/download/linyu19872008/4179367), I unzipped to the same directory as the installation of Python, Entering redis-2.0.2, here are a few files:

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 on its plain text protocol.
Redis-check-dump.exe Local Database Check
Redis-check-aof.exe Update Log Check
Redis-benchmark.exe performance test to simulate the sending of M-sets/gets queries (similar to Apache AB tools) by n clients at the same time

Benchmark Tool Test Information:

Send 100,000 requests to the Redis server with 60 concurrent clients per request

Gee, my computer is a little overwhelmed, but eventually it shows 4.03 seconds to complete 100,000 requests.

Some of the results of the screenshot are as follows:

Start the Redis service (conf file Development profile (Redis-server.exe redis.conf), if not specified, default):

Start the cmd window to be open all the time, then close the Redis service.

At this time the service is open, another CMD window to set up the client:

Copy Code code as follows:

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

And then we can type in the command we want to enter here, and redis a very important operation is set and get

The client is as follows:

At this point the server side (which is also native) is displayed as follows (one client is connected):

The above client-set key is resident memory, that is, close the window, the next window to open the value of the key or "Jzhou", hehe.

(Note that when the operation, the server side must open the service, otherwise the client is not connected.) )

Redis provides a variety of languages for clients, including Java,c++,python.

Python Operations Redis

To manipulate Redis in Python, you need to download a Redis Python Development Kit Redis-py (this web has https://github.com/andymccurdy/redis-py) After downloading it, I put it in the Python installation directory, go into the redis-py directory, execute setup.py (download Setuptools, then execute python setup.py install OK)

A few seconds on the installation, into the Python environment, hehe, do something to show that Redis import successfully:

I quit CMD and wanted to import Redis directly in the Python IDE, but the import failed, prompting no such module, and I thought, oh, I should add the redis-py path to the system environment variable so that Python could recognize it, and if so, I would "c:\ Python27\redis-py ", joined the system path, again in the python from the IDE operation Redis succeeded, so do not have to every time in the black box of CMD entered.

First class, if there is a mistake, please point out redis.

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.