I. A brief introduction of NoSQL
Before reprinted a series of NoSQL articles, speaking very systematic and comprehensive, so here is only a simple mention. NoSQL refers to "non-relational databases" and is often translated into notonly Sql. NoSQL is the most used when the number of key-value storage, of course, there are other document-type (example: Mongo), column storage, graph database, XML database and so on.
Such databases are different from traditional relational databases and do not necessarily follow the basic requirements of traditional databases, such as SQL standards, ACID (transactional) Properties, fixed table structures, and so on. These databases typically have the following characteristics: Open source, non-relational, easily distributed, horizontally scalable, data-easy to migrate (because there is no fixed table).
They run on inexpensive PC server clusters (smashing performance bottlenecks), handle high concurrent reads and writes to data, efficiently store and access ultra-large amounts of data, and are highly scalable and highly available for data.
Second, Redis introduction
Redis is a key-value store database in four NoSQL categories. It is an open source, advanced key-value, often referred to as a data structure server. Because it supports stored value types can contain (string) strings, (list) lists, (hash) hashes, (set) collections, (Zset) ordered collections, and many other data structures.
It supports many rich data operations such as Add/remove, Push/pop, intersection/set, and sorting in a variety of different ways. To ensure efficiency, REDIS data is cached in memory, and of course it supports two persistence schemes, that is, it can periodically write updated data to disk or write modifications to appended log files.
third, the API language
Redis provides almost all the operating APIs for mainstream languages, including C, C + +, C #, Java, PHP, Perl, Python, Ruby, objective-c, JavaScript, and more.
Iv. applications in the real world
It is said that the country's largest redis users are "Sina Weibo", there are more than 200 physical machines in Sina, more than 400 ports are running Redis, there is +4g data on Redis to provide services for Weibo users. There are a number of Redis deployment scenarios in Sina Weibo, which can be divided into the following two types:
1. Application direct access to Redis database
2, the application direct access to Redis, when the Redis access failed, then direct access to MySQL
v. Applicable scenarios
1, take the latest n data operation
2, the leaderboard application, take top n operation
3, need to accurately determine the expiration time of the application
4. Counter Application
5, Uniq operation, to obtain a period of time all data row weight value
6, real-time system, anti-spam system
7, pub/sub build real-time message system
8. Build the queue system
9. Cache
vi. Comparison of storage structures with MySQL and MongoDB
Vii. Installation and startup under Windows
First download the Redis server file under Windows. and decompression, such as:
The directory is then added to the PATH environment variable:
Then double-click Redis-server.exe to open the server "Of course, if you want to start with redis.windows.conf configuration file, cmd command: Redis-sever.exe redis-windows.conf", Example: (shows 0 clients connected to the server)
Then double-click Redis-client.exe to start the client, such as:
And then we look at the server, and now we have 1 clients connected to the servers.
Then we can manipulate the Redis database through the client, for example:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
redis--Introduction