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

04 data type 1:string

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

Share

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

# introduction to string

String type is the most basic data type of redis. A key corresponds to a value, and a key can store a maximum 512Mb.

String is binary secure.

# Common commands:

> set mykey "dang"

OK

> get mykey

"dang"

> set mykey "nihao" # multiple assignments will overwrite the original value

OK

> get mykey

"nihao"

> mset key1 1 key2 2 key3 e # multiple assignments

OK

> mget key1 key2 key3 # take multiple values

1) "1"

2) "2"

3) "e"

> setnx mykey 111I returned 0

(integer) 0

> setnx mykey2 111 # returns 1

(integer) 1

> get mykey2

"111"

# setnx if key exists, 0 is returned, and the existing value is not overwritten. The key is created directly if it does not exist.

> setex key6 30 yes # sets the expiration time, with the validity period in front and the value in the end

OK

> ttl key6 # gets the expiration time. If there is no expiration time,-1 is returned.

(integer) 25

> ttl mykey2

(integer)-1

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

Wechat

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

12
Report