TokyoTyrant::add
(PECL tokyo_tyrant >= 0.1.0)
TokyoTyrant::add — Adds to a numeric key
Descrição
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.
Parâmetros
-
key -
The string key
-
increment -
The amount to increment
-
type -
TokyoTyrant::RDBREC_INTorTokyoTyrant::RDBREC_DBLconstant. If this parameter is omitted the type is guessed from theincrementparameters type.
Valor Retornado
Returns the new value on success
Exemplos
Example #1 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);
?>
O exemplo acima irá imprimir algo similar à:
6.5
Veja Também
- TokyoTyrant::put() - Puts values
- TokyoTyrant::putcat() - Concatenates to a record
- TokyoTyrant::putkeep() - Puts a record