This isn’t a blog. It’s a notebook.
APCu Functions
Arguments in []’s are optional. Cross reference with APC docs. PECL Page. Github.
Iterator functions are omitted, but also available.
The above is a cleaned up version of what’s output by "php --re apcu"
.
Perl-like ?: Operator
From Tips.
Data Format: Raw PHP variables (var_export)
To serialize something to disk in the fastest way PHP can read it, you make it source code by calling var_export. Whenever the file changes, it should cause a cache miss with OPcache.
To use it:
Alternatively, if you store it a different way:
But this will cause OPcache to miss every time.
Data Format: JSON (decode, encode)
Apparently this is the fastest encoder, as of PHP 5.3. Benchmarks.
json_decode, json_encode, json_last_error
Data Format: Serialize, Unserialize
A faster decoder (slower encoder), and types/classes persist.
Data Format: IGbinary
An alternative, external binary encoder/decoder. According to benchmarks, the fastest.
https://github.com/igbinary/igbinary (PECL)
Smaller too.
Tips and Tricks:http://ilia.ws/files/zendcon_2010_hidden_features.pdf
Data Format: CSV
Reading Only.
http://php.net/manual/en/function.str-getcsv.php
Data Format: XML
Reading Only (there is writing, but it seems more difficult).
If you prefer Array format (like me), here’s a function.
Then simply
Data Format: HTML
Use Simple HTML DOM parser.
http://simplehtmldom.sourceforge.net/ (Manual)