TokyoTyrant::add

(PECL tokyo_tyrant >= 0.1.0)
Adds to a numeric key
public number TokyoTyrant::add ( string $key, number $increment [, int $type = 0 ] )

Adds to an int or double value. This increments the value by the given amount and returns the new value. If the key does not exist a new key is created with initial value of the increment parameter.

Parameters:
key

The string key

increment

The amount to increment

type

TokyoTyrant::RDBREC_INT or TokyoTyrant::RDBREC_DBL constant. If this parameter is omitted the type is guessed from the increment parameters type.

Returns:

Returns the new value on success

Examples:
TokyoTyrant::add() example
<?php
$tt = new TokyoTyrant("localhost", TokyoTyrant::RDBDEF_PORT);
/* Adds integer 3 to key and creates a new key */
$tt->add("test", 3);

/* String value is converted to double */
echo $tt->add("test", "3.5", TokyoTyrant::RDBREC_DBL);
?>

The above example will output something similar to:

6.5
See also:

TokyoTyrant::put() -

TokyoTyrant::putcat() -

TokyoTyrant::putkeep() -

doc_php
2016-02-24 16:18:46
Comments
Leave a Comment

Please login to continue.