## multi, exec, discard.
##### Description
Enter and exit transactional mode.
進入、退出事務處理模式。
##### Parameters
(optional) `<span class="calibre12">Redis::MULTI</span>` or `<span class="calibre12">Redis::PIPELINE</span>`. Defaults to `<span class="calibre12">Redis::MULTI</span>`. A `<span class="calibre12">Redis::MULTI</span>` block of commands runs as a single transaction; a `<span class="calibre12">Redis::PIPELINE</span>` block is simply transmitted faster to the server, but without any guarantee of atomicity. `<span class="calibre12">discard</span>`cancels a transaction.
multi函數的參數選項為Redis::MULTI或者是Redis::PIPELINE.默認的是參數是Redis::MULTI。
Redis::MULTI將多個操作當做一個事務來處理。Redis::PIPELINE將作為一個簡單快速的處理通道給服務器進行處理,但是不保證處理數據的原子性。
discard()函數取消一個事物處理模式。
##### Return value
`<span class="calibre12">multi()</span>` returns the Redis instance and enters multi-mode. Once in multi-mode, all subsequent method calls return the same object until `<span class="calibre12">exec()</span>` is called.
multi()返回一個Redis實例,并且這個實例進入到了事務處理模式(批量處理)。當進入到事務處理模式,所有的方法調用都將返回相同的Redis實例,一直到exec()被調用執行事務處理。
##### Example
```
<pre class="calibre9">$ret = $redis->multi()
->set('key1', 'val1')
->get('key1')
->set('key2', 'val2')
->get('key2')
->exec();
/*
$ret == array(
0 => TRUE,
1 => 'val1',
2 => TRUE,
3 => 'val2');
*/
```
- php-redis中文幫助手冊
- 系統及通用函數
- construct
- connect,open
- pconnect, popen
- close
- setOption
- getOption
- ping
- echo
- randomKey
- select
- move
- rename, renameKey
- renameNx
- setTimeout,expire,pexpire
- expireAt,pexpireAt
- keys,getKeys
- dbSize
- auth
- bgrewriteaof
- slaveof
- object
- save
- bgsave
- lastSave
- type
- flushDB
- flushAll
- sort
- info
- resetStat
- ttl, pttl
- persist
- config
- eval
- evalSha
- script
- getLastError
- _prefix
- _unserialize
- dump
- restore
- migrate
- time
- String數據類型函數
- get
- set
- setex, psetex
- setnx
- del, delete
- getSet
- multi, exec, discard
- watch, unwatch
- subscribe
- publish
- exists
- incr, incrBy
- incrByFloat
- decr, decrBy
- mGet, getMultiple
- append
- getRange
- setRange
- strlen
- getBit
- setBit
- bitop
- bitcount
- mset, msetnx
- List數據類型相關函數
- lPush
- rPush
- lPushx
- rPushx
- lPop
- rPop
- blPop, brPop
- lSize
- lIndex, lGet
- lSet
- IRange,IGetRange
- lTrim,listTrim
- lRem,lRemove
- lInsert
- rpoplpush
- brpoplpush
- Set數據類型相關函數
- sAdd
- sRem, sRemove
- sMove
- sIsMember, sContains
- sCard, sSize
- sPop
- sRandMember
- sInter
- sInterStore
- sUnion
- sUnionStore
- sDiff
- sDiffStore
- sMembers, sGetMembers
- zSet數據類型相關函數
- zAdd
- zRange
- zDelete,zRem
- zRevRange
- zRangeByScore, zRevRangeByScore
- zCount
- zRemRangeByScore,zDeleteRangeByScore
- zRemByRank,zDeleteRangeByRank
- zSize,zCard
- zScore
- zRank,zRevRank
- zIncrBy
- zUnion
- zInter
- Hash數據類型相關函數
- hSet
- hSetNx
- hGet
- hLen
- hDel
- hKeys
- hVals
- hGetAll
- hExists
- hIncrBy
- hIncrByFloat
- hMset
- hMGet