Redis Learning Notes---string types

Source: Internet
Author: User

Add

Some of the key points in the previous note blog are not mentioned, now add

    • Redis help command

The help command should be a command that we use frequently with any of our software products, and sometimes we can get assistance faster by helping commands, not just through Baidu. Similarly, the help name in Redis is very simple and easy to understand, although it is only available in English. But as long as there is a certain application basis of the people can read, such as:

127.0. 0. 1:6379> HELPREDIS-CLI3.0. 2Type:"Help @<group>"  to Get aList ofCommandsinch<group>"Help <command>"  forHelpOn   <command>      "Help <tab>"  to Get aList ofPossible Help topics"Quit"  toExit127.0. 0. 1:6379> HelpSet # #set命令的介绍SET Keyvalue[EXseconds] [PXmilliseconds] [nx| XX] Summary:set the string value  of aKey since:1.0. 0Groupstring
You can also check Redis's Chinese help here at http://redisdoc.com/
    • Redis Configuration


      Redis sets the database parameters through the configuration file. This configuration if you choose the default settings at the time of installation, there should be 6379.conf in the/etc/redis directory, and of course, you can specify the configuration file when you start the Redis service. Here is a brief introduction to some common configurations, The REDIS-CLI can be used to view related configurations, or to view them directly from profile 6379.conf. Each configuration has detailed information, more than 100 configurations, but the configuration file is close to thousands of lines, indicating never seen such detailed configuration instructions.
      The following is a simple general configuration

 127.0. 0. 1:6379> ConfigGet*# View all the configuration information 127.0. 0. 1:6379>configSetLogLevel Warning# #可以在不重启redis的情况下更改redis的部分配置 127.0. 0. 1:6379>configGetLogLevel# #获取redis配置 127.0. 0. 1:6379>configGetDatabases# #默认支持字典的个数 (similar to the number of databases in a relational DB instance), the default value is 16, you can modifyRedis>configGetDir# #aof和rdb文件的存放位置Databases - # #最大数据库数, counting from zero, i.e. [0,databases-1]AppendOnly Yes# # Opens the AOF setting, while placing the snapshot feature in a low priority position, about AOF related content is described separately.
Redis data types

Redis provides five types of data structures, respectively,

    • string-string
    • hash-Dictionary
    • list-List
    • set-Collection
    • Sorted Set-ordered Collection
Redis Common data Types-string types
127.0.0.1:6379>help@string ##获取string类型相关命令的帮助信息

Set key value
Get key
Mset key value [key value ...], setting multiple key
Mget key [key ...] to get multiple key-value pairs simultaneously
Such as:

127.0. 0. 1:6379> Mset K1 v1 k2 v2 K3 V3ok127.0. 0. 1:6379> mget K1 K2 k3getset keyvalue # #在为一个键设置新的值时返回旧的值, returns nil if the key does not exist127.0. 0. 1:6379> Getset K1 Test"V1"127.0. 0. 1:6379>GetK1"Test"127.0. 0. 1:6379> Getset K5 V5 (nil)127.0. 0. 1:6379>GetK5"V5"

Strlen key to get the length of a key value

GetRange key start end, gets the character at the specified position of a key value, supports negative index, -1 is the last position

127.0  .0  .1 : 6379  > GetRange K1 Span class= "Hljs-number" >0 -1   "test"  Append key value  # #在某键值的末尾增加新字符串  127.0  .0  .1 : 6379  > Append k1 " test ... " () 13  127.0  .0  .1 : 6379  > get  k1 "test test ..."   

INCR No #为整数型的键值增加1
Incrby no increment #为数字型的键值增加指定大小的整数 (increment)
Incrbyfloat No increment #为数字型的键值增加指定大小的浮点数
DECR No1 #为整数型的键值减1
Decrby No1 Decrement # #为数字型的键值减去指定大小的整数
Note: Without the decrbyfloat command, you can use the Increbyloat command to subtract the floating-point size

127.0.0.1:6379> SetNo 1Ok127.0.0.1:6379> GetNo"1"127.0.0.1:6379> incrNo(integer)2127.0.0.1:6379> IncrbyNo Ten(integer) A127.0.0.1:6379> GetNo" A"127.0.0.1:6379> IncrbyfloatNo 0.001"12.001"
Reference

Redis Getting Started Guide

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Redis Learning Notes---string types

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.