apcu_* are the new names for apc_* functions in PHP 7
See https://github.com/krakjoe/apcu
Wanted to implement myself, but it is all in C++ code.
Should be pretty straightforward though.
If this can be done by wrapping the existing ones, can be implemented in php easily - the php files with <<__Native>> in can also contain non-native functions.
@fredemmott Since v5.1.0 (first version compatible with PHP7) apcu_inc() and apcu_dec() create non existing keys, and apc versions return error in that case. https://github.com/krakjoe/apcu/commit/5c9e477fa620f096debbd76adb860b0093166636
Does it mean that apcu extension should be written in c++?
I also think it would be nice to have APCU
+1 for this since apc is not supported in php 5.5+ but apcu is.
This problem is because hhvm only supports apc per https://github.com/facebook/hhvm/search?q=apc&type=Code&utf8=%E2%9C%93
Are these just alternate names for the apc functions? If there are notable differences could someone here outline them? It should be pretty easy to supply aliases for these names.
@paulbiss no, apc was removed in php 5.5 and apcu was then created.
Maybe we could just invite @krakjoe to this discussion to outline the differences in behavior between apc_* and apcu_* functions (if there are any).
@paladox right, but the hhvm implementation of apc is completely distinct from the php implementations of both apc and apcu. What I'm getting at is, were there any API level changes besides s/apc_/apcu_/ or was it just a new set of names and a shiny new implementation?
The hhvm implementation of apc is highly tuned for speed and memory efficiency, it's unlikely we would want to replace it wholesale, but if there are functions that need to be added or aliased that's something we can certainly do.
@nazar-pc good idea!
Oh, would we be able to add an apcu version? or at least add alias for apcu, so if users use apcu functions they would alias to apc, as apcu is just the same as apc just it works only on php 5.5+?
This would benefit Wikimedia's https://gerrit.wikimedia.org/r/#/c/299498/ since then we could possibly drop apc functions and go with apcu since we wont need backward compat for hhvm.
please?
Yeah we could definitely do that! I'd like to hear from @krakjoe or someone else familiar with any potential behavioral differences, but adding aliases or new entry points with slightly modified behavior as appropriate is totally doable.
Oh, thankyou :), would you know when that can be done?
@paulbiss I am under the understanding that APCu is just the userdata component of the old APC, without the bytecode caching.
For a full replacement of APC in PHP 5.5+ you need both APCu for userdata and OpCache for the bytecode caching
So if we are aliasing the userdata component of HHVM-APC to APCu I think it makes sense to consider also aliasing the HHVM-APC bytecode caching to OpCache (although OpCache has more features than APC did so that may suggest a different course of action)
@photodude, I believe you don't need opcache-related part of APC, since HHVM already uses JIT and works very differently internally. Only user data part is relevant here.
We don't actually do any OpCode caching in APC. HHVM has its own bytecode cache (stored to disk as an sqlite repo and persisted in memory during execution, persists between server restarts), as well as a translation cache (persists only in memory during process execution, persists between requests). There's also no way to turn it off, the VM will only execute bytecode from the cache and the frontend writes there first.
@nazar-pc @paulbiss Thanks for the clarification.
I took a quick look and it seems APCu does have one additional method that APC does not have
apcu_entry — Atomically fetch or generate a cache entry
I didn't dig much deeper into the other 22 methods in both APCu and APC to see if all the details of the methods match up.
| APCu function | APC function |
| --- | --- |
| array apcu_cache_info ([ bool $limited = false ] ) | array apc_cache_info ([ string $cache_type = "" [, bool $limited = false ]] ) |
| bool apcu_clear_cache ( void ) | bool apc_clear_cache ([ string $cache_type = "" ] ) |
| public APCUIterator::__construct ([ mixed $search = null [, int $format = APC_ITER_ALL [, int $chunk_size = 100 [, int $list = APC_LIST_ACTIVE ]]]] ) | public APCIterator::__construct ( string $cache [, mixed $search = null [, int $format = APC_ITER_ALL [, int $chunk_size = 100 [, int $list = APC_LIST_ACTIVE ]]]] ) |
I did find there is some documentation issues in the PHP manual (not all APCu documentation is correct as some of it is still APC info)