Redis basic Commands

Source: Internet
Author: User

Redis itself does not differentiate between the case of commands, which are all lowercase, and the following are some simple commands.

1.keys (... Get all the key information, if the amount of data is large, will affect performance, output will only output the key name, preceded by an ordinal prefix, parameter support regular.

127.0.0.1:6379>Keys F*1) "Fo"2) "F"127.0.0.1:6379>Keys*1) "Test"2) "Fo"3) "F"

2.exists (...) The test key exists, and there is a return of 1, otherwise 0 is returned.

127.0. 0.1:6379>exists  w (integer0127.0.  0.1:6379>exists  fo (integer1

3.del (...) Delete the command, followed by the key name, delete successfully returned 1, otherwise return 0,del does not support wildcard characters, but can be combined with the system's own ARGX command, for example: Redis-cli keys "*" | Xargs redis-cli del.

127.0. 0.1:6379>  del fo (integer1127.0.  0.1:6379>  del fo #已经删除过一次了, then delete will return 0. (integer0

4.type (...) View the type of the key and return none if it does not exist.

127.0. 0.1:6379>  type fstring127.0. 0.1:6379>  type Fonone

The 5.set/get setting gets the information and returns nil if it does not exist.

127.0. 0.1:6379>set  t1 tOK127.0. 0.1:6379>  get T1 "T"127.0. 0.1:6379>  get T2 (nil)

6.INCR (...) to increment the numeric string and return the incremented value, if there are multiple client operations on the same one, Redis guarantees that the operation is atomic and does not cause concurrency problems.

127.0.0.1:6379> SetT11OK127.0.0.1:6379>Get T1 "1"127.0.0.1:6379>incr T1 (integer)2127.0.0.1:6379>Get T1 "2"

7.append (...) Append to tail

127.0.0.1:6379>get F "1"127.0.0.1:6379>append f lll (integer)4127.0.0.1:6379>get F "1lll"

8.strlen (...)

127.0. 0.1:6379>  strlen F (integer4

9.mset (...) /mget (...) Gets the setting of multiple key values.

127.0.0.1:6379>Mset F11F22F33OK127.0.0.1:6379>mget F1 F2 f31) "1"2) "2"3) "3"

Redis basic Commands

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.