APCu Extension Added to Seiden PHP+
PHP sites and APIs on IBM i have a new way to run even faster. As noted in our Seiden PHP+ Changelog, we have added the APCu extension to our PHP distribution.
The APC User Cache (APCu) extension is an “in-memory key-value store for PHP” that evolved from the old APC extension (minus the opcode caching). We added APCu at the request of a Linux PHP user who migrated their PHP application to the IBM i to simplify their architecture.
Here is a sample script from the apcu_store() manual page. It stores a value in a named key, then retrieves it.
|
1 2 3 4 5 6 7 |
<?php $bar = 'BAR'; // Store the value in memory with the name 'foo' apcu_store('foo', $bar); // Retrieve value var_dump(apcu_fetch('foo')); // string(3) "BAR" ?> |
When this script is run from a web or API application, the keyed value will remain in memory, available to all PHP web jobs, until either the value is cleared, the web server is restarted, or the optional time-to-live (ttl) seconds have passed.
Optional features include a way to load multiple key/value pairs at once, even a whole table, so long as it fits in memory.
For the full list of functions, see the APCu manual page: https://www.php.net/manual/en/ref.apcu.php
To install this extension in an existing Seiden PHP+ installation, use the ACS Open Source Package Management window, or from an SSH terminal, run yum install "php-apcu". Then restart your web server.

Leave a Reply
Want to join the discussion?Feel free to contribute!