forked from LinkedDestiny/swoole-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhanglei5
committed
Dec 5, 2014
1 parent
0dc2610
commit d824a30
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,3 +165,26 @@ lock/unlock之间的代码,应当try/catch避免抛出异常导致跳过unlock | |
```php | ||
swoole_table->unlock() | ||
``` | ||
## 整体使用案例 | ||
```php | ||
$table = new swoole_table(1024); | ||
$table->column('id', swoole_table::TYPE_INT, 4); //1,2,4,8 | ||
$table->column('name', swoole_table::TYPE_STRING, 64); | ||
$table->column('num', swoole_table::TYPE_FLOAT); | ||
$table->create(); | ||
|
||
$table->set('[email protected]', array('id' => 145, 'name' => 'rango', 'num' => 3.1415)); | ||
$table->set('[email protected]', array('id' => 358, 'name' => "Rango1234", 'num' => 3.1415)); | ||
$table->set('[email protected]', array('id' => 189, 'name' => 'rango3', 'num' => 3.1415)); | ||
|
||
$data = $table->get('[email protected]'); | ||
$table->del('[email protected]'); | ||
$table->lock(); | ||
/** | ||
事务性处理。 | ||
**/ | ||
$table->unlock(); | ||
|
||
count($table); // 获得有多少条记录。 | ||
``` | ||
个人感觉如果要是可以获得table里所有的key就好了,因为get是要根据key来获取记录的。 |