Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Strings type and operation of redis

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Set

Set the value of key to value of type string.

Such as: set name HongWan

Setnx

Set the value of key to value of type string. If key already exists, returning 0menthnx means not exist.

For example, setnx name HongWan returns 0 (the setting is not successful because it already exists)

Setex

Set the value of key to value of type string, and specify the validity period for this key.

Such as: set name 10 HongWan

Setrange

Sets the substring of the value value of the specified key. Replace the original value from the specified subscript.

Such as: setrange email 7 qq.com

Mset

Set multiple key values at a time. A successful return of ok means all values have been set, while a failure return of 0 means no values have been set.

Such as: mset key1 val1 key2 val2...

Msetnx

Set multiple key values at a time. A successful return of ok means that all values have been set. A failure return of 0 means that no values have been set, but the existing key will not be overwritten.

Get

Gets the string value corresponding to key, and returns nil. Nil if key does not exist.

Getset

Sets the new value of key and returns the old value of key. If key does not exist, it returns nil.

Such as: getset mykey myvalue

Getrange

Gets a substring of the value value of the specified key. When the subscript exceeds the length of the string, it defaults to the maximum subscript in the same direction. And you can use a negative subscript.

For example, getrange key 03; getrange key-7-1

Mget

Get the values of more than one key at a time. If the corresponding key does not exist, nil is returned.

Such as: mget key1 key2 key3

Incr

Add the value of key and return the new value. Note that incr A value that is not int will return an error, and if incr a key that does not exist, set key to 1

Incrby

Similar to incr, with a specified value, key is set when key does not exist, and the original value is considered to be 0

Such as: incrby age 5

Decr

The value of key is subtracted. If there is no key in decr, set key to-1.

Decrby

Same as decr, minus the specified value.

Append

Appends a value to the string value of the specified key and returns the length of the new string value.

Strlen

Takes the length of the value value of the specified key.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report