increment
(Requires Workerman version >=3.3.0)
bool \GlobalData\Client::increment(string $key[, int $step = 1])
Atomic increment. Increases a numeric element by the size specified by the parameter step. If the value of the element is not a numeric type, it will be treated as 0 for the increment operation. Returns false if the element does not exist.
Parameters
$key
Key value. (For example, $global->abc; here, abc is the key value)
$step
The size by which to increase the element's value.
Return Values
Returns true on success, otherwise returns false.
Example
$global = new GlobalData\Client('127.0.0.1:2207');
$global->some_key = 0;
// Non-atomic increment
$global->some_key++;
echo $global->some_key."\n";
// Atomic increment
$global->increment('some_key');
echo $global->some_key."\n";