Memcache::flush

(PECL memcache >= 1.0.0)

Memcache::flushLimpa todos os itens existentes no servidor

Descrição

Memcache::flush(): bool

Memcache::flush() invalida imediatamente todos os itens existentes. Memcache::flush() não libera nenhum recurso, ele apenas marca todos os itens como expirados, então a memória ocupada será substituída por novos itens. Também pode ser usada a função memcache_flush().

Parâmetros

Esta função não possui parâmetros.

Valor Retornado

Retorna true em caso de sucesso ou false em caso de falha.

Exemplos

Exemplo #1 Exemplo de Memcache::flush()

<?php

/* API procedural */
$memcache_obj = memcache_connect('memcache_host', 11211);

memcache_flush($memcache_obj);

/* API orientada a objeto */

$memcache_obj = new Memcache;
$memcache_obj->connect('memcache_host', 11211);

$memcache_obj->flush();

?>

adicione uma nota

Notas Enviadas por Usuários (em inglês) 2 notes

up
9
maarten d/ot manders a/t tilllate dotcom
17 years ago
Please note that after flushing, you have to wait a certain amount of time (in my case < 1s) to be able to write to Memcached again. If you don't, Memcached::set() will return 1, although your data is in fact not saved.
up
6
Anonymous
17 years ago
From the memcached mailing list:

"The flush has a one second granularity. The flush will expire all items up to the ones set within the same second."

It is imperative to wait at least one second after flush() command before further actions like repopulating the cache. Ohterwise new items < 1 second after flush() would be invalidatet instantaneous.

Example:
<?php
$memcache
->flush();

$time = time()+1; //one second future
while(time() < $time) {
//sleep
}
$memcache->set('key', 'value'); // repopulate the cache
?>
To Top