String manipulation of Python-redis

Source: Internet
Author: User
Tags time in milliseconds install redis

Tag: false body failed string sudo set value execution log

Ubuntu installation Redis

[Email protected]:~$ sudo apt install redis-server[email protected]:~$ redis-server[email protected]:~$ redis-cli

Set (key, value, Ex=none, Px=none, Nx=false, Xx=false)
Set the value in Redis, not exist then create, overwrite if present

Ex is the value's expiration time in seconds

PX is the value of the expiration time in milliseconds

If NX is set to true, the current set operation is performed only if the key does not exist

XX If set to True, the current set operation is performed only if key exists

127.0.0.1:6379> set name johnok127.0.0.1:6379> get name  # gets the value in name "John" 127.0.0.1:6379> set name Jackok127.0.0.1:6379> get name  # overrides the original value "Jack" 127.0.0.1:6379> set age 2  # causes the value in age to survive for 2 seconds OK127.0.0.1 :6379> get Age "127.0.0.1:6379> get" (nil)  # It's not worth the time to find the value 127.0.0.1:6379> set  Live 2000 ms Ok127.0.0.1:6379> get Age "127.0.0.1:6379> get" (nil)  # It's not worth the time to find the value. 127.0.0.1:6379> Set Name Jack NX  # because name exists, so the set operation failed (nil) 127.0.0.1:6379> set name_1 Jack NX  # because Name_1 does not exist, the set operation succeeds OK127.0.0.1 :6379> set name John xx  # because name exists, so the set operation executes successfully ok127.0.0.1:6379> set name_1 John NX  # because Name_1 does not exist, So the set operation failed to execute (nil)

String manipulation of Python-redis

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.