Redis string Type related Operations Command

Source: Internet
Author: User
Tags uppercase letter truncated

The string is the most basic type of redis and can include any type of data, such as a JPG picture or a serialized object.

Maximum limit for a single value1 is 1G bytes

If you use only string types, Redis can be seen as a memcache with persistent properties

Set key value [ex Expiration Time second number]| [PX Expiration time milliseconds] [nx]| [XX] Sets the value of a key, the type of default value is string
EX,PX expiration time, if set at the same time as the following, such as set name Zhangsan ex ten PX 3000, then the following time is 3 seconds
NX: Indicates that the key does not exist when the operation is performed
XX: Indicates that the key exists when the operation is performed

Get key gets the value of key

Mset key1 value1 key2 value2 .... KeyN Valuen setting values for multiple keys at once

Mget key1 key2 .... KeyN get multiple key values at once

INCR key to the value of the key to do the Gaga operation, and return the new value, if the key does not exist then create a key and set a value of 1, there will be the original value plus 1, but the original value must be an integer type

DECR key to decrement the value of key and return the new value

Incrby key Integer adds the value of key to the specified value integer

Decrby key integer Subtracts the value of the key by the specified value integer

Incrbyfloatkey key Floatnumber Adds the value of the key to the floating-point number Floatnumber

Append key value appends value to the string value of the specified key, which is equivalent to string concatenation

SUBSTR Key Start End returns the string value of the truncated key, containing the start and end positions

SetRange Key offset value shifts the string from the offset byte position to value, offset from 0, value has a few bytes to replace several bytes
If offset offsets exceed the string length, the middle position is automatically \0x00
Such as
Set name Hello
SetRange name 6?
So name becomes "hello\x00?"

GetRange key [start stop] gets the character of the string start to the stop position, indexed starting at 0, including the start and stop position characters
Note:
1.start>=strlength, the empty string is returned
2.stop>=strlength, truncated to the end of the string
3. Returns an empty string if start is located on the right side of stop

Getset key NewValue gets and returns the original value of the key while setting the new value to NewValue

Getbit key offset Gets the value of key on the offset bit from the bit angle (offset starting from 0, left to right)
Example: Set char A a====>65 (assic) ====>0100 0001
Getbit Char 1 returns 1
Getbit Char 2 returns 0

Setbit key offset value set key at offset position from the angle of the bit
such as: conversion of uppercase and lowercase letters
A 65 0100 0001
A 97 0110 0001
Uppercase to lowercase you only need to add the Assic value of the uppercase letter to 32, corresponding to the 2nd bit on the byte
Set Char A
Setbit Char 2 1

Bitop Operation Deskey Key1[key2....keyn]
Operation operations on Key1,key2...keyn and saves the results to Deskey
Operation can be and, or, not, XOR

Redis string Type related Operations Command

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.