First knowledge of Redis

Source: Internet
Author: User

1. Introduction to Redis

Redis is a remote in-memory database that not only has strong performance, but also has replication features and a unique data model for solving problems. Redis provides 5 different kinds of data structures.

Redis is a very fast non-relational database (non-relational) that stores the mappings between keys and 5 different types of values (mapping), which persist data stored in memory to the hard disk, You can use replication attributes to extend read performance, and you can use client shards to extend write performance. Sharding: A method that divides data into parts, which can be based on the ID that the key contains, 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 get data from multiple machines, which can be used to achieve linear levels of performance improvement when solving certain problems.

2. Introduction to REDIS data structure

Redis can store mappings between keys and 5 different data structure types. These 5 types of data structures are string (string), list, set (set), hash (hash), and Zset (ordered collection), respectively.

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. There are, of course, other commands for reading and writing some of the contents of a string, as well as some commands that can perform self-increment or decrement operations on numeric values stored in strings. We will study in the following chapters.

List command: Rpush: Pushes the given value into the right end of the list. Lpush: Pushes the given value into the left side of the list. Lpop: POPs a value from the left side of the list and returns the value that was popped. Rpop: POPs a value from the right end of the list and returns the value that pops up. LINDEX: Gets the single element of the list at the given position. Lrange: Used to get all the elements of a list at a given range (using a range starting range of 0, 1 is the end index, you can take out all the contents of the list)

Collection command: Sadd: Adds the given element to the collection. Srem: If the given element exists in the collection, then the element is removed. Smembers: Returns all the elements contained in the collection. Sismember: Checks whether the given element exists in the collection. In addition to the basic additions and deletions, the collection also supports other operations such as Sinter, Sunion, and Sdiff, which perform common intersection operations, set operations, and differential set operations, respectively.

Hash command: The hash value can be either a string or a numeric value, and the user can also perform an auto-increment or decrement operation on the numeric value of the hash store. Hset: A given key-value pair is associated with a hash, and when an attempt is made 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 that the hash contains. Hdel: If the given key exists in the hash, remove the key.

Ordered set: An ordered set is the only structure in Redis that can access elements based on the member's access to the element and the sort order of the score and the score. Zadd: Adds a member with the given value to the ordered collection


This article is from the "Ah Cool blog source" blog, please make sure to keep this source http://aku28907.blog.51cto.com/5668513/1828919

First knowledge of Redis

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.