Redis series (a): small scale chopper

introduction

With the rapid development of Internet, traditional relational databases (such as MySQL, Microsoft SQL Server, etc.) can not meet the growing business needs, such as the timeliness of a very strong function of commodity spike, buy, etc., with highly concurrent access to applications, will cause the system to crash database, in order to solve this situation, you need to reference a cache middleware, the market is more commonly used caching middleware has Redis and Memcached, they each have their own advantages and disadvantages, but generally Internet companies were powered by MySQL + Redis of the concept focuses on Redis way of architecture, described in the installation and configuration.

Brief introduction

concept

Redis (Remote Dictionary Server) is an open source use written in ANSI C, BSD comply with the agreement and support network, based on the persistence of memory can log type, Key-Value database, and provides multi-lingual non-relational API database.

Traditional database follows the ACID rules. The Nosql (Not Only SQL acronym, is a generic name for Unlike traditional relational database management system database) is generally distributed and distributed generally follow the CAP theorem.

It Memcached and the like, which supports the stored value relatively more types, including string (string), List (list), SET (set), zset (sorted set - ordered set) and hash (hash type). These data types are supported push / pop, add / remove and on the intersection and union, and difference richer operation, and these operations are atomic. On this basis, redis support a variety of different ways of sorting. Like with memcached, in order to ensure efficiency, the data is cached in memory. Redis difference is that will periodically update the data written to disk or to modify the operation of writing additional log file, and on this basis realize the master-slave (master-slave) synchronization, the cluster mode Redis Release 3.0 version.

Github Source: https://github.com/antirez/redis

Redis official website: https://redis.io/

Features, Advantages

  • k, v, and a data structure stored key-value store (e.g., lists, dictionaries)
  • All the data (including stored data) operations are done in memory
  • Single-threaded service (which means there will be more obstruction), the use of epoll model request response, compared to nginx
  • Support master-slave replication mode, but also provides high availability master-slave replication mode (Sentinel)
  • Decentralized distributed clusters
  • Rich programming interface support, such as Python, Golang, Java, php, Ruby, Lua, Node.js 
  • Feature-rich, in addition to supporting a variety of data structures, but also supports transactions, publish / subscribe, message queues, and other functions
  • Support for data persistence (AOF, RDB)

Contrast memcache

  • memcache is a distributed memory object caching system does not provide persistent storage capabilities and redis has a persistent feature
  • memcache data storage based on LRU (Simply put: Recently, the least-used key is removed), and redis can be saved permanently (the service has been under operation)
  • memcache is multithreaded (which is one of the advantages of memcache), which means less obstruction case, and redis are single-threaded, obstruction relatively more
  • Little difference on both performance
  • memcache supports only simple k, v data storage, and stores a variety of data formats redis support.
  • memcache is multi-threaded, non-blocking IO multiplexing network model, which is single-threaded IO redis reuse model

Install Windows version

Redis of windoms version Download: https://github.com/microsoftarchive/redis/releases .

Download their version needs, as shown below (msi version is installed, zip is decompressed version):

Download the zip to a local decompression (I unpacked directory is D: \ Program Files \ Redis), the directory is as follows:

Open service, run CMD, switch to extract the directory, execute the following command (and set the maximum memory):

redis-server.exe redis.windows.conf --maxmemory 200M

Results as shown:

Open the command-line client, execute the following command:

redis-cli.exe

Add and queries Key-Value, execute the following command:

# Set the key
 the SET Key value 
# get key 
GET Key

Query and set a password, execute the following command:

# Password query 
config GET requirepass 
# password 
config the SET requirepass password

Enter the password, execute the following command:

auth password

More than a few commands, as shown below demonstrate.

 Sign up and unloading service, execute the following command:

# Sign Installation Services 
Redis -server --service-install redis.windows.conf - the LogLevel verbose 
# uninstall the service 
#redis -server --service-Uninstall

Implementation of the results, as shown below:

 After registration is complete, the service can be seen in the computer service, as shown in FIG.

 

 When you turn on the service, you can use the command line to connect directly to the client.

 to sum up

This paper briefly introduced Redis background, concepts and Windows versions of the installation and testing, in a subsequent post, we will continue to explain the content of Redis, if this article help you, is my writing power! Interested friends can add attention, welcome message exchange! 

Guess you like

Origin www.cnblogs.com/aizai846/p/12617254.html