$redis->muti($mode)->get($key)->set($key)->exec();
既然是這樣的, 也就是說當我要使用管道執行一萬次操做的時候須要寫一萬次操做在muti()的後面,,,仍是我找到更好的寫法?
設計者沒有想到這個問題麼?今天測試成功了php
Description: Enter and exit transactional mode.git
(optional) Redis::MULTI
or Redis::PIPELINE
. Defaults toRedis::MULTI
. A Redis::MULTI
block of commands runs as a single transaction; aRedis::PIPELINE
block is simply transmitted faster to the server, but without any guarantee of atomicity.discard
cancels a transaction.github
multi()
returns the Redis instance and enters multi-mode. Once in multi-mode, all subsequent method calls return the same object untilexec()
is called.redis
$ret = $redis->multi() ->set('key1', 'val1') ->get('key1') ->set('key2', 'val2') ->get('key2') ->exec(); /* $ret == array( 0 => TRUE, 1 => 'val1', 2 => TRUE, 3 => 'val2'); */
##############測試
簡單數據mget也能夠實現atom
Description: Get the values of all the specified keys. If one or more keys dont exist, the array will contain FALSE
at the position of the key.spa
Array: Array containing the list of the keys.net
Array: Array containing the values related to keys in argument設計
$redis->set('key1', 'value1'); $redis->set('key2', 'value2'); $redis->set('key3', 'value3'); $redis->mGet(array('key1', 'key2', 'key3')); /* array('value1', 'value2', 'value3'); $redis->mGet(array('key0', 'key1', 'key5')); /* array(`FALSE`, 'value2', `FALSE`);