|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #59787 enable OpCodeCache for eval() / streams
Submitted: 2011-05-26 06:39 UTC Modified: 2013-02-18 21:21 UTC
Avg. Score:4.5 ± 0.5
Reproduced:9 of 9 (100.0%)
Same Version:6 (66.7%)
Same OS:3 (33.3%)
From: mail at rodneyrehm dot de Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.3.5 OS: Mac OS X 10.6.7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: mail at rodneyrehm dot de
New email:
PHP Version: OS:


 [2011-05-26 06:39 UTC] mail at rodneyrehm dot de
Tools like Smarty ( dynamically compile php code. If written to disk, APC may cache the file. If saved to some other storage system (database, memcache, ?) the code/string has to be eval()ed.

eval()ed code is currently not cachable by APC means, which makes non-FS storage of code not as optimal as it could be.

There are two possible approaches:

(1) apc_eval(string $key, [string $code]) to evaluate and cache opcodes
(2) allow APC to cache streams as include "mystream://my-file-name"

The first option would be limited to eval()ed code and probably demand new API functions. The second option could be somewhat seamlessly integrated into the already existing file-functions.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-22 18:11 UTC] luke at cywh dot com
I really want this as well. In my case I'm generating logic based on HTML 
templates on the fly and need to execute this logic from a remote database. The 
PHP box itself is sand-boxed, and the code is signed so it cant be modified.

For us saving these templates to disk doesn't make sense since there will be 
thousands of them. We want to minimize disk activity for these PHP boxes as much 
as possible.

For us eval() makes the most sense in this situation. The only reservation is 
this code isn't opcode cached. A function like apc_eval would make the most 
sense for us, although it should probably be broken up into:

apc_code_store(string $key, string $code [, int $ttl])
apc_code_eval(string $key)

And if there needs to be:

apc_code_delete($string $key)

(Although if apc_delete could be used, that would be fine)

It would also be interesting to be able to do:

apc_fetch($string $key)

To get the opcode in binary form. Perhaps have the ability to store this in a 
database and transmit it to other machines and do:

apc_store($key, $opcode)

And then:

 [2013-02-18 21:21 UTC]
As much as the idea is interesting, the massive difference in the way apc user 
and opcode caches work makes this a really big feature.

I would suggest using a ramdisk to dump the generated files which would be about 
as fast and wouldn't leak memory - apc_bin* stuff leaks memory as it does not 
allow for any partial unloading, all we can do is flush the whole cache to get 
rid of it.

I'm closing this because it won't get fixed, not because it can't be,
 [2013-02-18 21:21 UTC]
-Status: Open +Status: Wont fix
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Feb 28 13:01:27 2024 UTC