A classe APCUIterator

(PECL apcu >= 5.0.0)

Introdução

A classe APCUIterator torna mais fácil iterar sobre grandes caches APCu. Ela é útil pois permite iterar sobre grandes caches em etapas, capturando um número definido de entradas por instância de trava, portanto ela libera as travas de cache para outras atividades ao invés de segurar todo o cache para capturar 100 entradas (que é o padrão). Além disso, usar correspondências com expressões regulares é mais eficiente pois opera no nível de linguagem C.

Resumo da classe

class APCUIterator implements Iterator {
/* Métodos */
public function __construct(
    array|string|null $search = null,
    int $format = APC_ITER_ALL,
    int $chunk_size = 100,
    int $list = APC_LIST_ACTIVE
)
public function current(): mixed
public function getTotalCount(): int
public function getTotalHits(): int
public function getTotalSize(): int
public function key(): string
public function next(): bool
public function rewind(): void
public function valid(): bool
}

Índice

adicionar nota

Notas de Usuários 1 note

up
0
olliejones at gmail dot com
1 day ago
To delete all variables from the data store with keys starting with a particular $prefix, do this.

<?php
foreach ( new APCUIterator( '/^' . preg_quote( $prefix, '/' ) . '/', APC_ITER_KEY ) as $item ) {
    apcu_delete( $item['key'] );
}
?>

It is good practice to choose a distinctive prefix for all key names. Some server configurations cause multiple domains' code to share one APCu cache, and distinctive prefixes prevent cache variable name collisions.
To Top