Introduction to Redis:
First, Introduction
In the past few years, NoSQL databases have become synonymous with high-concurrency, massive data storage solutions, and the corresponding products have sprung up. However, there are only a handful of products that can stand out, such as Redis, MongoDB, BerkeleyDB and Couchdb. Because each product has different characteristics, so there are some differences in their application scenarios, the following is only a simple explanation:
1). BerkeleyDB is an extremely popular open-source embedded database that can be used in more situations for storage engines, such as BerkeleyDB, which was previously used as a storage engine for MySQL before it was acquired by Oracle, thus anticipating the excellent concurrency scalability of the product. Supporting transactions and nested transactions, massive data storage and other important features, in the storage of real-time data for the very high value available. However, it should be noted that the licence of the product is the GPL, which means that it is not used for free in all cases.
2). The definition for MongoDB is oriented-document database server, and unlike BerkeleyDB, the database can run independently as other relational database servers and provide related data services. From the official documentation of this product we can be informed that MongoDB is mainly applicable to high-concurrency forums or blog sites, these sites have the main characteristics of high concurrent access, read less write, large data volume, simple logic relationship, as well as document data as the main data source. Like BerkeleyDB, the license of the product is the same as the GPL.
3). Redis, a typical NoSQL database server, can operate independently of its own server host as a service program, compared to BerkeleyDB. In many cases, people just treat Redis as a Key/value database server, but that's not the case, and in the current version, Redis supports data structures such as list, Hash, set, and ordered set in addition to Key/value. So it's also more broadly used. For this misunderstanding, the Redis official website has also been clarified accordingly. Unlike the above two products, Redis's License is Apache License, and for now it is completely free.
4). memcached, data cache server. Why should we give an explanation of the product here? Very simple, because I think it is most similar to Redis in the way it is used. After all, this is a technical blog about Redis, and for this reason, we will briefly compare the two products. First of all, the biggest difference between them, memcached just provides the data caching service, once the server is down, the previously cached data in memory will all disappear, so you can see that memcached does not provide any form of data persistence, and Redis provides such a function. Another is that Redis provides a richer data storage structure, such as hash and set. As for their similarities, there are two main points, one of which is completely free, and then there is the very close order form they provide.
Second, Redis and memcache contrast
650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M02/7D/E5/wKiom1byQCqhx6IZAABIx5156-w662.png "title=" 445. PNG "alt=" Wkiom1byqcqhx6izaabix5156-w662.png "/>
Persistence: E-commerce example, session with Memcache to do, shopping cart with Redis to do, when you exit will be prompted in the shopping cart items will remain after you exit. Relatively memcache storage is more single!
Master-slave replication: Redis's master-slave replication is similar to MySQL's master-slave replication but the principle is different!
Virtual memory: To put the memory of some of the unused things on the hard disk, it is best not to use, reduce efficiency, now the memory is relatively cheap.
Redis Installation & Basic operations:
1. Check the configuration environment to check if GCC is installed, if not installed: YUM -Y INSTALL GCC2, install redis# wget # cd /usr/next week local/redis# make && make install# cd src# make test # Problems that may be encountered during installation:zmalloc.h:50:31: error: jemalloc/jemalloc.h: no such file or directoryzmalloc.h:55:2: error: #error "newer version of jemalloc required" allocator-----------------------------------------------------------------------selecting a non-default memory allocator when building redis is done by settingthe ' MALLOC ' environment variable. redis is compiled and linked against libcmalloc by default, with the exception of jemalloc being the default on Linuxsystems. This default was picked Because jemalloc has proven to have fewerfragmentation problems than libc malloc. to force compiling against libc malloc, use:% make malloc=libcto compile against jemalloc on mac os x systems, use:% make Malloc=jemalloc allocator (Assignment operator), if there is a malloc this environment variable, will be useful for this environment variable to establish Redis. And libc is not the default allocator, the default is jemalloc! Because Jemalloc is proven to have fewer fragmentation problems than libc. But if you don't have jemalloc and only libc of course make error. So add such a parameter. MAKE MALLOC=LIBC-----------------------------------------------------------------------
Redis installation and Redis data types