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 __construct(
    array|string|null $search = null,
    int $format = APC_ITER_ALL,
    int $chunk_size = 100,
    int $list = APC_LIST_ACTIVE
)
public current(): mixed
public getTotalCount(): int
public getTotalHits(): int
public getTotalSize(): int
public key(): string
public next(): bool
public rewind(): void
public valid(): bool
}

Índice

adicionar nota

Notas de Usuários 1 note

up
0
olliejones at gmail dot com
22 days 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