Redis learning (3): Redis data types

tags: [Database] Redis  database  redis  Big Data  hadoop

Redis data types

There are a total of five data types supported in redis,Respectively string string typelist typeSet typeHash table type and ordered set zset type, Through these five different data types, we can achieve a variety of different functions, and can also be applied to a variety of different scenarios. Next, let’s take a look at the operation syntax of the five data types.

The structure of various data types in redis is as follows:

Operation of various data types in redis

Operations on String in Redis

The following table lists commonly used redis string commands

Operation of Hash list in Redis

  • Redis hash is a mapping table of String type field and value. Hash is especially suitable for storing objects.
  • Each hash in Redis can store 232 -1 key-value pair (over 4 billion)

The following table lists the basic redis hash related commands:

Operation of List in Redis

  • The Redis list is a simple list of strings, sorted in the order of insertion. You can add an element to the head (left) or tail (right) of the list
  • A list can contain up to 232 -1 element (4294967295, each list has more than 4 billion elements).

The following table lists the basic commands related to the list:

Operations on Set collections in Redis

  • The Set of redis is an unordered collection of String type. Set members are unique, which means that no duplicate data can appear in the set.
  • In Redis, collections are implemented through hash tables, so the complexity of adding, deleting, and looking up is O(1).
  • The maximum number of members in the set is 232 -1 (4294967295, each set can store more than 4 billion members).

The following table lists the basic commands of the Redis collection:

Key operations in Redis

The following table shows the basic commands related to Redis keys:

Database in Redis

Redis supports multiple databases, and the data of each database is isolated and cannot be shared, and is based on a single machine. If it is a cluster, there is no concept of a database.

Redis is a storage server with a dictionary structure. In fact, a Redis instance provides multiple dictionaries for storing data. The client can specify which dictionary to store the data in. This is similar to the well-known fact that multiple databases can be created in a relational database instance, so each dictionary can be understood as an independent database.

Each database is externally named with an increasing number starting from 0. Redis supports 16 databases by default (more can be supported through configuration files, no upper limit), and this number can be modified by configuring databases. After the client establishes a connection with Redis, it will automatically select the 0 database, but you can use the SELECT command to replace the database at any time. If you want to select the 1 database:

node01:6379> select 1
node01:6379[1]> keys *

Clear the data in the redis database

node01:6379> flushdb

Clear data in all redis databases

node01:6379> flushall 

Intelligent Recommendation

Redis Learning 2.1: Introduction to Redis data types

surroundings: Redis:3.2.10 ; CentOS 6/7 Summary description: Redis supports five data types: string (string), hash (hash), list (list), set (set) and zset (sorted set: ordered set); This chapter mainl...

Redis learning (1) Redis data types and commands

Redis data type 1. Data Type String hash hash list list set collection sorted_set (zset) ordered set View the complete redis command: http://www.redis.cn/commands.html 2. String type 2.1 set command:s...

Redis Data Types of Redis Learning (Day 32)

Redis data types Redis supports five data types: string (string), hash (hash), list (list), set (collection) zset (sorted set: ordered set) string The most basic type, a key corresponds to a value. It...

Redis learning (two) a Redis data types and commands

Redis commands Redis supports five data types: String (string), hash (hash), set (collection), list (list) and zset (sorted set: ordered set), etc.。 Common command key management Key naming suggestion...

Redis learning summary (3)-operation of list and hashset data types

table of Contents First, List data type 1.1 Overview: 1.2 List of related commands: 1.3 Command example: 1.4 Tips for linked list structure: Two, HashSet data type 2.1 Overview: 2.2. List of related c...

More Recommendation

Redis learning data types and operations

Redis learning data types and basic operations Foreword In the previous section, we learned about Redis installation, client usage, etc. In this section, we will learn about the five data structures a...

Chapter 3: Redis data structure types

Five data structures: string (String), string list (list), sorted set (sorted set), hash (hash), string set (set). The following describes the application of string: Get all keys Obtained value: Delet...

Redis(3) five data types and API operations

This section includes: Five redis data types and operations Python operation redis code 1 string The redis command is not case sensitive, but the data in the redis distinguished by the key are all str...

Redis five data types and commands (3)

Redis five data types and commands (3) Redis set (Set): single value and multiple values, disorder and no repetition 1.sadd key members: Add one or more elements to the collection. If the elements are...

Redis data types and operations (3): set type

One set type A set is a set, which is similar to the concept of a set in our mathematics. The operations on a set include adding and deleting elements, and operations such as intersecting and subtract...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top