Redis data Type (a) string

Source: Internet
Author: User

REdis is stored in key-value pairs, so it's called a dictionary test. Redis (Remote dictionary server) long-range dictionary server

each Redis data type will have the ability to add, delete, view, and use instances to learn commands. Let's start with a single string operation, followed by a bulk string operation

================================== The following is the addition of a single character, starting ===============================

Instance operations:

1. Add a character type store the author is the Zhangnala operation, the key is author

command format: set key value

Solution: Set author Zhangnala

Note: Do not add semicolons to the end of key and value without commas

2. Judge author this key is not in

Command format:exists key

Solution: Exists author

Note: If the return is 1, is present, if return is 0, this key does not exist

3. Get the value of the author key

command format: get key

Solution: Get Author

Answer: Zhangnala

4. Give author this key corresponding to the value that is Zhangnala, append string (Kimi)

command format: append key "Append string"

Solution: Append Author "Kimi"

Answer: Zhangnalakimi

Note: Remember that the string needs to be appended with double quotation marks wrapped up, if the key value does not exist, then the execution is a set operation, such as Append eglishname Kimi, this eglishname key dry Ben does not exist, Then the Redis internal actually performs the operation of set eglishname Kimi;

5. Get the string length

For example, get the length of the value that corresponds to the author key

command format: strlen key

Solution: Strlen Author

Answer: 13

6. Remove the author button

command format:del key

Solution: Del author

=========================================== The following is a bulk Add/remove character, starting ===============================

1. Add a name named Xiao Li, height 1.60 of the data

command format: mset key1 value1 key2 value2

Solution: Mset name Xiaoli hight 1.60

Note: There is no need to add a comma between the key and value, the bulk of the key-value pairs, the comma is not used between the separation, the end of the time do not use the customary semicolon

2. Bulk get the value of the Name,hight key

command format: mget key

Solution: Mget name Hight

Answer: Xiaoli

1.60

3. Remove the

=========================================== Extended Operation ===============================

1. Get the data type of the key value (first: string "character type" second: hash "hash Type", Third: List "type", Fourth: Set "collection type", Fifth: Zset "ordered set type")

Command: Type key

such as: type name

Answer: String

2. View all key values

Keys *

3. Clear all the key values that exist in Redis, and then clear the library Delete db in a similar database.

Command: Flushall or FLUSHDB

Redis data Type (a) string

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.