Redis tutorial (a key-value high-performance database)

What redis that?

Redis is an open source use written in ANSI C, support network, based on the persistence of memory can log type, Key-Value database, and provides multi-lingual API. And Memcached Similarly, it supports relatively more stored value type, comprising a 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 periodically updated in the data written to disk or to modify the operation of writing additional log file, and on this basis realize the master-slave (master and slave) synchronization.

redis appears, to a large extent compensate for the lack of such memcached key / value store, it can play a very good complement to relational database in some situations. It provides Java, C / C ++, C #, PHP, JavaScript, Perl, Object-C, Python, Ruby, Erlang and other clients, very easy to use.
Redis supports master-slave synchronization. Data can be synchronized from the primary server to an arbitrary number from the server, the server may be associated with the primary server from another server. This allows the tree Redis single executable copy. Intentionally or unintentionally, can save the data write operation. Since the full implementation of the publish / subscribe mechanism, so that the database synchronization from a tree anywhere, can subscribe to a channel and receive the full message master server publishing record. Synchronization scalability and redundancy data useful for a read operation.

edis storage

redis uses two file formats: full and incremental amount of data requests.
The total amount of data format is the data in memory to disk, to facilitate the next read a file is loaded;
delta file request is the data memory into a sequence operation request for reading a file replay data obtained, the sequence include operation of the SET, RPUSH, SADD, ZADD.
redis stored into memory storage, disk storage and log files of three parts, the configuration file has three parameters to configure it.
save seconds updates, save the configuration, noting how long, how many times the update operation, the data will be synchronized to the data file. This can be used with a number of conditions, such as the default settings in the configuration file, it set three conditions.
appendonly yes / no, appendonly configuration, indicate whether logging after every update operation, if not open, may result in data over a period of time when power is lost. Because redis itself to synchronize data file is based on the above conditions to save synchronized, so some data will exist only in the memory for some time.
appendfsync no / always / everysec, appendfsync configuration, no means other operating systems synchronized data cache to disk, always represents a manual update operation after each call fsync () writes data to the disk, everysec represents synchronization once per second.

 

Redis Introduction

 

Redis is completely free open source, BSD comply with the agreement, it is a high-performance key-value database.

 

 

 

Redis and other key - value caching product has the following three characteristics:

 

  • Redis supports data persistence, data in memory can be kept on disk, restart when you can load be used again.
  • Redis only supports simple key-value data types, while also providing a storage list, set, zset, hash and other data structures.
  • Redis supports backup data, i.e., data backup master-slave mode.

 


 

Redis advantage

 

  • High performance - Redis can read as fast as 110,000 times / s, write speed is 81000 times / s.
  • Rich data types - Redis supports binary case Strings, Lists, Hashes, Sets and Ordered Sets the data type of the operation.
  • Atomic - Redis All operations are atomic, and atomic Redis also supports the implementation of the whole operation and several.
  • Feature-rich - Redis also supports publish / subscribe, notification, key expiration and so on characteristics.

 


 

Redis and other key-value store What is the difference?

 

  • Redis has a more complex data structure and provide atomic operations on them, which is different from the other databases evolutionary path. Meanwhile Redis data types are based on the basic data structure transparent to the programmer, without the need for additional abstraction.
  • Redis running in memory, but can be persisted to disk, so that when the high-speed read and write memory tradeoffs different data sets, the data should not be greater than the amount of hardware memory. Another advantage of in-memory databases are, compared to the same complex data structures, operate in a very simple memory on the disk, so you can do a lot of internal Redis highly complex matter. Meanwhile, in terms of their compact disk format to generate additional way, because they do not require random access.

    Redis installed

    Created by the lichiabor, youj last modified 2015-09-16

    Redis installed

    Under Window Installation

    Download: https://github.com/dmajkic/redis/downloads .

    Installation Instructions: https: //www.w3cschool.cn/redis/redis-install.html

 

Guess you like

Origin www.cnblogs.com/lukelook/p/11136577.html