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

How to use exec of redis in php

2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use the exec of redis in php". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to use the exec of redis in php.

In Redis, exec is used to execute commands within all transaction blocks, and the return values of all commands within the transaction block are arranged in the order in which the commands were executed. When the operation is interrupted, the null value "nil" is returned, and the syntax is "redis > Exec".

This article operating environment: Windows10 system, PHP7.1 version, Dell G3 computer.

What is the use of exec of redis in php

The Redis Exec command is used to execute commands within all transaction blocks.

The basic syntax for redis Exec commands is as follows:

Redis 127.0.0.1 6379 > Exec

Return value

The return values of all commands within the transaction block are arranged in the order in which the commands were executed. Returns a null value of nil when the operation is interrupted.

Examples are as follows:

# transaction executed successfully redis 127.0.0.1 INCR user_idQUEUEDredis 6379 > INCR user_idQUEUEDredis 127.0.0.1 INCR user_idQUEUEDredis 6379 > INCR user_idQUEUEDredis 127.0.0.1 INCR user_idQUEUEDredis 6379 > INCR user_idQUEUEDredis 127.0.0.1 INCR user_idQUEUEDredis 127.0.1 PONG# Monitoring key 12) (integer) 23) (integer) 34) PONG# Monitoring key And the transaction successfully executes redis 127.0.0.1 MULTIOKredis 6379 > MULTIOKredis 127.0.0.1 MULTIOKredis 6379 > SET lock "huangz" QUEUEDredis 127.0.0.1 MULTIOKredis 6379 > INCR lock_timesQUEUEDredis 127.0.0.1 MULTIOKredis 6379 > EXEC1) OK2) (integer) monitor key And the transaction was interrupted redis 127.0.0.1 redis 6379 > MULTIOKredis 127.0.0.1 MULTIOKredis 6379 > SET lock "joe" # just then, another client modified the value of lock_times QUEUEDredis 127.0.0.1joe 6379 > INCR lock_timesQUEUEDredis 127.0.0.1 joe 6379 > EXEC # because lock_times was modified, joe transaction execution failed (nil) to this point I believe you have a deeper understanding of "how to use the exec of redis in php", so you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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