About NoSQL
Before I introduce Redis, I'd like to know about NoSQL, not just SQL, which is a non-relational data store with Key/value key-value pairs. Existing NoSQL DB product: Redis/mongodb/memcached/hbase/cassandra/tokyo cabinet/voldemort/dynomite/riak/couchdb/hypertable/ FLARE/TIN/LIGHTCLOUD/KIOKUDB/SCALARIS/KAI/THRUDB, wait ~ ~ ~
Why do I need a nosql non-relational database?
- High performance-demand for highly concurrent reads and writes to the database
- Huge Storage-The need for efficient storage and access to massive amounts of data
- High Scalability && High availability-requirements for database scalability and availability
about Redis
With Membercache and a variety of databases, why is Redis generated? Redis is purely for applications, and it is a high-performance Key-value database. The emergence of Redis, to a large extent, compensates for the memcached of such keyvalue storage, solves the situation that the data is completely lost after power outage, and in some cases can be a good complement to the relational database. The performance test results indicate that the set operation can be up to 110,000 times per second, and the get operation is 81,000 times/sec (of course different Server configuration performance differs).
Redis is a distributed NoSQL database system for "key/value" type data, characterized by high performance, persistent storage, and adapting to high concurrency scenarios. similar to memcached, it supports storing more value types, including string (string), list (linked list), set (set), and Zset (ordered collection). These data types support Push/pop, Add/remove, and intersection sets and differences and richer operations, and these operations are atomic and support a variety of different ways of sorting . Redis is like memcached, where 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 currently offers four types of data: String,list,set and Zset (sorted set).
The Redis storage is divided into memory storage, disk storage, and log files, which are configured with three parameters in the configuration file.
- Save seconds Updates: Indicates how many times the update operation has been synchronized to the data file.
- AppendOnly yes/no: Whether to log records after each update operation. If it is not turned on, it may result in loss of data over a period of time when power is lost. Because the Redis itself synchronizes data files in sync with the save conditions above, some data will only exist in memory for a period of time.
- Appendfsync no/always/everysec: How the data cache is synchronized to disk. No indicates that the data cache of the operating system is synchronized to disk, always indicates that the data is written to disk manually after each update operation, and EVERYSEC indicates that synchronization occurs every second.
installation and use of Redis under Windows
First download Redis online, I downloaded the redis-2.0.2, I extracted to the same directory as the installation of Python, into the redis-2.0.2, following these files:
redis-server.exe Daemon launcher for Redis server
redis.conf redis profile
redis-cli.exe REDIS command Line Operations tool. Of course, you can also use Telnet to manipulate the
Redis-check-dump.exe Local database check
redis-check-aof.exe Update log check
redis-benchmark.exe performance test to simulate the simultaneous sending of M sets/gets queries by n clients (similar to Apache's AB tool)
Benchmark Tool Test Information:
Send 100,000 requests to the Redis server with 60 concurrent clients per request
Gee, my computer is a bit too tired, but it finally showed 4.03 seconds to complete the 100,000 request test,
Some of the results are as follows:
start the Redis service (conf file development configuration file (Redis-server.exe redis.conf), default if not specified):
Start the cmd window to remain open, and the Redis service shuts down when it is closed.
When the service is open, another CMD window is opened and the client is set:
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, and one of the important things about Redis is set and get
The client is as follows:
At this point the server side (which is also native) appears as follows (one client is connected):
The above in the client set the key is resident memory, is to close the window, the next time to open the window get key value or "Jzhou", hehe.
(Note that the server must turn on the service, otherwise the client will not connect.) )
Redis provides clients in multiple languages, including Java,c++,python.
NoSQL's test using under Windows Redis