Swoole table

Swoole table is a high performance memory management module, implemented based on shared memory and spin lock.

In order to keep the data synchronization, have to use Swoole\Lock if the memory is modified and accessed by multiple threads or processes.

Swoole table provides a two dimensions memory table for developers.

Why to use swoole table

public Swoole\Table::__construct ( integer $table_size )

Alias: swoole_table->__construct($table_size);

Construct a Swoole memory table with size.

public int Swoole\Table::column ( string $name , string $type [, integer $size ] )

Alias: swoole_table->column($name, $type, $size = 0)

Set the data type and size of the columns.

public void Swoole\Table::create ( void )

Alias: boolean swoole_table->create()

Create the swoole memory table.

public void Swoole\Table::set ( string $key , array $value )

Alias: swoole_table->set(string $row_key, array $value)

Update a row of the table by $row_key.

public integer Swoole\Table::get ( string $row_key , string $column_key )

Alias: swoole_table->get(string $row_key, string $column_key)

Get the value by $row_key and $column_key.

public void Swoole\Table::del ( string $key )

Alias: swoole_table->del(string $row_key)

Delete a row by $row_key.

public boolean Swoole\Table::exist ( string $key )

Alias: swoole_table->exist(string $row_key)

Check if a row is existed by $row_key.

public void Swoole\Table::incr ( string $key , string $column [, integer $incrby ] )

Alias: swoole_table->incr(string $row_key, string $column_key, integer $incr_by = 1)

Increment the value by $row_key and $column_key.

public void Swoole\Table::decr ( string $key , string $column [, integer $decrby ] )

Alias: swoole_table->decr(string $row_key, string $column_key, integer $decr_by = 1)

Decrement the value by $row_key and $column_key.

public integer Swoole\Table::count ( void )

Alias: integer swoole_table->count($mode = 0);

Count the rows in the table, or count all the elements in the table if $mode = 1.

public void Swoole\Table::destroy ( void )

Alias: boolean swoole_table->destroy()

Destroy the memory table.

public void Swoole\Table::rewind ( void )

Alias: swoole_table->rewind()

PCRE is needed for this function

public void Swoole\Table::next ( void )

Alias: swoole_table->next()

PCRE is needed for this function

public array Swoole\Table::current ( void )

Alias: array swoole_table->current()

PCRE is needed for this function

public string Swoole\Table::key ( void )

Alias: swoole_table->key()

PCRE is needed for this function

public boolean Swoole\Table::valid ( void )

Alias: swoole_table->valid()

PCRE is needed for this function

Iterator and Countable

The iterator and countable depends on pcre-devel

foreach($table as $row)
echo count($table);