(Requires Workerman version >= 3.3.0)

bool \GlobalData\Client::increment(string $key[, int $step = 1])

Atomic increment. Increases a numerical element by the size specified in the $step parameter. If the value of the element is not a numeric type, it is treated as 0 before the increment operation. Returns false if the element does not exist.



The key. (For example, in $global->abc, abc is the key)


The size by which to increment the element's value.

Return Value

Returns true on success, false otherwise.


$global = new GlobalData\Client('');

$global->some_key = 0;

// Non-atomic increment

echo $global->some_key."\n";

// Atomic increment

echo $global->some_key."\n";