downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Memcached::prepend> <Memcached::getVersion
Last updated: Fri, 20 May 2011

view this page in

Memcached::increment

(PECL memcached >= 0.1.0)

Memcached::incrementIncrementa el valor númerico del ítem

Descripción

public int Memcached::increment ( string $key [, int $offset = 1 ] )

Memcached::increment() incrementa el valor numérico del valor del ítem por el offset especificado. Si el valor del ítem no es numérico, es tratado como si su valor fuera 0. Memcached::increment() producirá un error si el ítem no existe.

Parámetros

key

La clave del ítem a incrementar.

offset

La cantidad a incrementar el valor del ítem.

Valores devueltos

Devuelve el valor del nuevo ítem en caso de éxito o FALSE en caso de error. El Memcached::getResultCode() devolverá Memcached::RES_NOTFOUND si la clave no existe.

Ejemplos

Example #1 Ejemplo de Memcached::increment()

<?php
$m 
= new Memcached();
$m->addServer('localhost'11211);

$m->set('counter'0);
$m->increment('counter');
$m->increment('counter'10);
var_dump($m->get('counter'));

$m->set('key''abc');
$m->increment('counter');
?>

El resultado del ejemplo sería:

int(11)
string(1) "1"

Ver también



add a note add a note User Contributed Notes Memcached::increment
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites