Home>Article>Database> What is Redis

What is Redis

青灯夜游
青灯夜游 Original
2019-02-13 17:42:01 25020browse

Redis is a very fast open source non-relational database that stores key mappings of five different types of values. Used as a database, cache and message broker. The following article will introduce Redis, I hope it will be helpful to everyone.

What is Redis

What is Redis?

Redis is an in-memory key-value database, often called a data structure server. One of the main differences between Redis and other key-value databases is Redis's ability to store and manipulate advanced data types. These data types are the basic data structures that most developers are familiar with (lists, maps, sets, and sorted sets). Redis' superior performance, simplicity, and atomic operations on data structures help solve problems that are difficult to implement or perform poorly using traditional relational database implementations.

Main features of Redis

Advanced data structure: Provides five possible data types for values: string, Lists, sets, hashes and sorted sets. Operations unique to these data types are provided and have well-documented time complexity (Big O notation).

High performance: Due to its in-memory nature, the project maintainers' commitment to keeping complexity to a minimum, and the event-based programming model, Redis has excellent performance for read and write operations.

Lightweight with no dependencies: Written in ANSI C, no external dependencies. Works in all POSIX environments. Windows is not officially supported, but Microsoft offers an experimental version.

High availability: Built-in support for asynchronous, non-blocking, master/slave replication to ensure high availability of data. There is a high availability solution called Redis Sentinel that is currently available but is still considered a work in progress.

Redis features:

The following are some of the most important Redis features:

● Memory cache: Due to its high performance , when the volume of read and write operations exceeds the capabilities of a traditional database, Redis can easily persist data to disk,

● Support for publish/subscribe: Redis provides the function of distributing data using the publish/subscribe messaging paradigm. .

● Automatic reconnection support

● Lua script

● Key lifetime is limited

● LRU eviction key

● Automatic failover

● Built-in replication

● Data structure supports string, hash, list, set, ordered set, bitmap, super log, geospatial index

Redis supports data structures and can store strings, lists, sets, and hashes. It provides interesting features such as built-in replication, LRU eviction, transactions, disk persistence and high availability. It provides automatic failover in a clustered environment; it can be used with most languages.

redis command example

Let me introduce the redis command

SET (SET key)

127.0.0.1:6379> SET foo“Hello World” OK // 设置密钥

GET (GET KEY)

127.0.0.1:6379> GET foo “Hello World”// 获取密钥

DEL (DELETE KEY)

127.0.0.1:6379> GET foo "Hello World" // 获取密钥 127.0.0.1:6379> DEL foo (integer) 1 // 密钥刚删除 127.0.0.1:6379> GET foo (nil) // 自密钥因此删除,结果为零。

SETEX ( Set the validity period of the key)

127.0.0.1:6379> SETEX foo 40“我说,Hello World!” OK // 键已设置为40秒到期

TTL (Total remaining time of the key)

127.0.0.1:6379> TTL foo (integer) 36 // 36秒后超时

The above is the entire content of this article, I hope it can be helpful to everyone Learning helps. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !

The above is the detailed content of What is Redis. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn