Introduction to Redis five data structures

Source: Internet
Author: User

Five types of Redis structure

1, String

It can be a string, an integer or a floating-point number, perform an operation on the entire string or part of a string, perform a self-increment (increment) or decrement (decrement) operation on the whole integer or floating point.

String command:

①get, gets the value stored in the specified key

②set, sets the value stored in the specified key

③del, deletes the value stored in the specified key (this command can be used for all types)

2. List

A linked list, each node on the list contains a string that pushes or pops the elements at both ends of the list, trims the linked list (trim) based on the offset, reads a single or multiple elements, finds or removes elements based on values.

List command:

①rpush, pushes the given value into the right end of the list

②lrange, gets all the values of the list at the specified range

③lindex, gets the single element of the list at the specified range

④lpop, pops a value from the left side of the list, and returns the value that was popped

3. Set

An unordered collector (unordered collection) that contains strings, and each string that is contained is unique. Adds, gets, removes a single element, checks whether an element exists in the collection, computes the intersection, sets the difference, and randomly gets the element from the collection.

Collection command:

①sadd, adding the given element to the collection

②smembers, returns all elements contained in the collection

③sismember, checks whether the specified element exists in the collection

④srem, checks whether the specified element exists in the collection, then removes the element

4, Hash

Contains key-value pairs of unordered hash lists, add, get, remove when key-value pairs, get all key-value pairs.

Hash command:

①hset, associating a specified key-value pair within a hash

②hget, gets the value of the specified hash key

③hgetall, gets all the key-value pairs that the hash contains

④hdel, if the given key exists in the hash, remove the key

5, Zset

An ordered mapping between a string member (member) and a floating-point score (score), in which the order of the elements is determined by the size of the score. Add, get, delete a single element, depending on the score range (range) or the member to get the element.

Ordered set command:

①zadd, adding a member with a given score to an ordered set

②zrange, based on the position of elements in an orderly arrangement, obtains multiple elements from an ordered set

③zrangebyscore, gets all elements of an ordered set within a given score range

④zrem, if the specified member exists in an ordered collection, remove the Member

Introduction to Redis five data structures

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.