## 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