Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

First acquaintance of Redis

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Introduction to Redis

Redis is a remote in-memory database with not only strong performance, but also replication and a unique data model created to solve problems. Redis provides five different types of data structures.

Redis is a very fast non-relational database (non-relational database), which can store the mapping between keys and 5 different types of values (mapping), can persist the key-value pairs stored in memory to the hard disk, can use replication features to expand read performance, and can use client sharding to expand write performance. Sharding: a method of dividing data into multiple parts, based on the ID contained in the key, the hash value based on the key, or some combination of the two. By slicing the data, users can store the data in multiple machines or obtain data from multiple machines. This method can achieve linear performance improvement when solving some problems.

2. Brief introduction of Redis data structure

Redis can store the mapping between keys and five different types of data structures. The five data structure types are STRING (string), LIST (list), SET (collection), HASH (hash), and ZSET (ordered set).

The string command: GET: gets the value stored in the given key. SET: sets the value stored in the given key. DEL: deletes the value stored in the given key. Of course, there are other commands that read and write part of the string, as well as commands that can perform self-increment or self-subtraction on the values stored in the string. We will learn in the following chapters.

List command: RPUSH: pushes the given value to the right end of the list. LPUSH: pushes the given value to the left of the list. LPOP: pops a value from the left end of the list and returns the popped value. RPOP: pops a value from the right end of the list and returns the pop-up value. LINDEX: gets a single element of the list at a given location. LRANGE: used to get all the elements of the list on a given range (using 0 as the starting range and-1 as the end index, you can take out all the contents contained in the list)

Collection command: SADD: add the given element to the collection. SREM: remove a given element if it exists in the collection. SMEMBERS: returns all the elements contained in the collection. SISMEMBER: checks whether a given element exists in the collection. In addition to the basic add and delete operations, the collection also supports other operations, such as SINTER, SUNION, and SDIFF. The three commands perform common intersection operations, union operations and subtraction operations, respectively.

Hash command: the value of the hash can be either a string or a numeric value, and the user can also increment or subtract the numeric value stored in the hash. HSET: associates a given key-value pair in the hash. When you try to add a key-value pair to the hash, the command returns a value indicating whether the given value already exists in the hash. HGET: gets the value of the specified hash key. HGETALL: gets all the key-value pairs contained in the hash. HDEL: if the given key exists in the hash, remove the key.

Ordered collection: an ordered collection is the only structure in Redis that can access elements not only according to members, but also based on scores and the order in which they are sorted. ZADD: adds a member with a given value to the ordered collection

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report