NoSQL non-relational database Redis (key-value pair (key-value) database) study notes

 

redis is a high performance NOSQL series of non-relational databases

 

1.1. What is NOSQL
            NoSQL (Not Only SQL NoSQL =), which means "not only SQL", is a new database concept, refers to non-relational database.


            With the rise of the Internet web2.0 websites, traditional relational databases in dealing with web2.0 sites, particularly large scale and high concurrent SNS type of web2.0 pure dynamic site has appeared to be inadequate, exposed a lot of problems difficult to overcome, rather than relational databases due to its own characteristics has been very rapid development. NoSQL database is generated in order to solve large-scale data collection of multiple data types of challenges brought about, especially in big data application problems.

            1.1.1 NOSQL and relational database comparison.
                Advantages:
                    1) Cost: nosql database is simple and easy to deploy, basically open source software, do not need to spend a lot like using oracle as the cost of purchase and use, compared to relational databases cheap.
                    2) query speed: nosql into the database stores data in cache, relational database stores data in the hard disk, far less than the natural query speed nosql database.
                    3) format to store data: nosql storage format is key, value form, the form of documents, pictures, forms, etc., can be stored in various formats as well as the basis of the type of objects or collections, etc., and the database only supports basic types.
                    4) Scalability: relational database query mechanism similar multi-table join such restrictions lead to expansion very difficult.

                Cons:
                    1) Maintenance of tools and materials is limited, because nosql belongs to new technologies, and not 10 years of relational database technology in the same category.
                    2) does not provide support for sql, if not support industry standards such as sql, it will have some users to learn and use cost.
                    3) does not provide a relational database processing of the transaction.

            1.1.2 Advantages non-relational databases:
                1) is based on a key to performance NOSQL, it is conceivable to the corresponding relationship between the primary key and the values in the table, and does not require the parsed SQL layer, the performance is very high.
                2) Scalability is also based on key-value pair because no coupling between the data, it is very easy to expand horizontally.

            1.1.3 The advantages of relational databases:
                1) complex queries can do very complex data queries between SQL statement in a convenient table and multiple tables.
                2) transaction support enables data access requirements for the safety of high performance can be achieved. For these two types of databases, the other advantage is their weakness, and vice versa.

            1.1.4 Summary
                relational databases and NoSQL databases are not opposing but complementary relationship that the use of relational databases under normal circumstances, the use of NoSQL NoSQL database for use when
                let NoSQL database for lack of relational database compensate.
                General stores the data in a relational database, data backup and storage in a relational database database nosql

 1.2 NOSQL mainstream products.
            •     key (Key-Value) store database
                    Related Products: Tokyo Cabinet / Tyrant,Redis , Voldemort, Berkeley DB
                    Typical applications: high access content caching, mainly used for processing large amounts of data load. 
                    Data model: a series of key
                    advantages: Quick Query
                    weaknesses: the lack of a structured data storage
            • column-store database
                    related products: Cassandra, HBase , Riak
                    Typical applications: distributed file system
                    data model: a column cluster storage, will exist in the same column data together
                    advantages: fast search speed, scalable, distributed more easily extend
                    disadvantages: relatively limited functions
            • document database
                    Related products: CouchDB, MongoDB
                    typical applications: Web applications (similar to the Key-Value, Value is structured)
                    data model: a series of key
                    advantages: the data structure is not strictly required
                    Disadvantages: query performance is not high, and the lack of a unified query syntax
            • Graphics (Graph) database
                    relational database: Neo4J, InfoGrid, Infinite Graph
                    Typical applications: Social network
                    data model: Figure structure
                    advantages: FIG structurally related algorithms.
                    Disadvantages: need to do in order to calculate the outcome of the whole map, not easy to do a distributed cluster program.

 

        1.3 What is the Redis
            Redis is provided with an open source, high-performance C language development of key (key-value) database, the official test data, 50 100 000 concurrent execution request, the read speed is 110 000 times / s, write speed is 81000 times / s, and storage requirements Redis to accommodate different scenarios by providing various types of key data, the key data so far Redis supported types are as follows:
                1) type string string
                2) hash type the hash
                . 3 ) list type list
                4) collection types the SET
                5) an ordered collection of type SortedSet
            1.3.1 Redis application scenarios
                • cache (data queries, short connections, news content, goods, content, etc.)
                online chat rooms • friends list
                • task queue . (Spike, buy, 12306, etc.)
                • Application chart
                • website statistics
                • stale data processing (accurate to milliseconds
                session separation • distributed cluster architecture

 

1.4 Redis download and install

 

  Official website: https: //redis.io/

  Chinese net: https://www.redis.net.cn/

  Download Linux version, (5.0.4 release 2019): http://download.redis.io/releases/

  There are Windows version on GitHub , (3.0.504 released in 2016) addresses are: https://github.com/MicrosoftArchive/redis

 

Linux version of the installation

$ tar zxvf redis-5.0.4.tar.gz
$ cd redis-5.0.4 $ make
$ src/redis-server  #启动服务器端
$ src/redis-cli     #启动客户端
redis> set foo bar #存储一个键值对 OK redis> get foo #查看刚刚的键 "bar"

Guess you like

Origin www.cnblogs.com/xin1006/p/12366991.html