apcu_add

(PECL apcu >= 4.0.0)

apcu_add Cache a new variable in the data store

Beschreibung

apcu_add(string $key, mixed $var, int $ttl = 0): bool
apcu_add(array $values, mixed $unused = NULL, int $ttl = 0): array

Caches a variable in the data store, only if it's not already stored.

Hinweis: Unlike many other mechanisms in PHP, variables stored using apcu_add() will persist between requests (until the value is removed from the cache).

Parameter-Liste

key

Store the variable using this name. keys are cache-unique, so attempting to use apcu_add() to store data with a key that already exists will not overwrite the existing data, and will instead return false. (This is the only difference between apcu_add() and apcu_store().)

var

The variable to store

ttl

Time To Live; store var in the cache for ttl seconds. After the ttl has passed, the stored variable will be expunged from the cache (on the next request). If no ttl is supplied (or if the ttl is 0), the value will persist until it is removed from the cache manually, or otherwise fails to exist in the cache (clear, restart, etc.).

values

Names in key, variables in value.

Rückgabewerte

Returns TRUE if something has effectively been added into the cache, FALSE otherwise. Second syntax returns array with error keys.

Beispiele

Beispiel #1 A apcu_add() example

<?php
$bar 
'BAR';
apcu_add('foo'$bar);
var_dump(apcu_fetch('foo'));
echo 
"\n";
$bar 'NEVER GETS SET';
apcu_add('foo'$bar);
var_dump(apcu_fetch('foo'));
echo 
"\n";
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

string(3) "BAR"
string(3) "BAR"

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

Berechnungen durchführen

Great discussion on calculations! As for the Wind Breaker' season 2 (https://gogoanime.by/series/wind-breaker-season-2/) I love how the subbed ver ...

Geschrieben von kamuar789 am 27.04.2025 21:19:26
Forum: PHP Developer Forum
Malaysia tour package

For anyone looking to experience the desert like never before, an overnight desert safari is a journey you won’t want to miss. Imagine camping u ...

Geschrieben von rogerwarner219 am 27.04.2025 20:48:59
Forum: Off-Topic Diskussionen
SEO-Optimierung: Der Schlüssel zu langfristigem Online-Erfolg

In einer digitalen Welt, in der täglich tausende neue Webseiten online gehen, wird die Auffindbarkeit im Internet zu einem der wichtigsten Erfolg ...

Geschrieben von Codini am 27.04.2025 12:58:26
Forum: Off-Topic Diskussionen
I need a jQuery timepicker plugin

For your booking system, you can use the jQuery Timepicker plugin, which allows easy customization, including disabling specific times on certain ...

Geschrieben von rogerwarner219 am 27.04.2025 09:44:24
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS