rfc:streams-is-cacheable
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:streams-is-cacheable [2015/01/03 12:39] – created francois | rfc:streams-is-cacheable [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Add is_cacheable() stream-wrapper operation ====== | ====== PHP RFC: Add is_cacheable() stream-wrapper operation ====== | ||
- | * Version: | + | * Version: 1.2 |
- | * Date: 2015-01-03 (Happy new year !) | + | * Date: 2015-01-04 |
* Author: François Laupretre, francois@tekwire.net | * Author: François Laupretre, francois@tekwire.net | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
- | |||
===== Introduction ===== | ===== Introduction ===== | ||
Line 14: | Line 13: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | All the features | + | When stream wrappers were introduced in PHP, their relationship with opcode |
+ | caches was not a problem, as they were mostly used to access remote data. The | ||
+ | need for a better interaction arose with package systems, like phar and phk, as | ||
+ | these stream wrappers manage a virtual PHP source tree through stream URIs. If | ||
+ | the scripts provided by such a system cannot be opcode-cached, | ||
+ | part of its value. | ||
- | To [[http:// | + | Historically, the issue was addressed using different workarounds : either every |
- | for inclusion in one of the world's most popular programming languages. | + | URI is considered |
+ | a list of ' | ||
+ | instance, opcache | ||
+ | is using the second solution : 'file' and ' | ||
+ | declared as the only ' | ||
+ | quick-and-dirty workaround and there is real need for a reliable and generic | ||
+ | way of determining whether an URI is cacheable. | ||
- | Remember that the RFC contents should be easily reusable in the PHP Documentation. | + | What I am proposing : |
+ | |||
+ | * An element named ' | ||
+ | structure. This is an optional pointer to a function able to determine if | ||
+ | a given URI is cacheable or not. This function receives an URI, an options | ||
+ | bitfield, and an optional context. It returns a value different of 0 if the | ||
+ | URI is cacheable. If the ' | ||
+ | are considered as non-cacheable. | ||
+ | |||
+ | * A new C function named php_stream_is_cacheable(const char *path, int options, php_stream_context *context) | ||
+ | is defined. It determines the right wrapper from the path it receives and | ||
+ | forwards the request to the corresponding stream_is_cacheable() function, if it | ||
+ | exists. If the stream_is_cacheable() element is not defined, 0 is returned. | ||
+ | |||
+ | * Userspace stream wrappers can define a method named is_cacheable(path [, | ||
+ | This method determines if the input path is cacheable and returns true or false. | ||
+ | If the method is not defined, every path for this wrapper are non-cacheable. | ||
+ | |||
+ | * For completeness, | ||
+ | is defined. It allows to determine from a PHP script whether a path is cacheable. | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 27: | Line 56: | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | 5.7, if released. Otherwise, | + | PHP 7. |
===== RFC Impact ===== | ===== RFC Impact ===== | ||
Line 36: | Line 65: | ||
==== To Existing Extensions ==== | ==== To Existing Extensions ==== | ||
- | Phar needs to implement an is_cacheable() function. This function | + | Phar needs to implement an is_cacheable() function, returning |
+ | |||
+ | The same for the plain files wrapper. | ||
==== To Opcache ==== | ==== To Opcache ==== | ||
- | Opcode caches | + | Opcode caches |
- | TODO | + | |
- | It is necessary to develop RFC's with opcache in mind, since opcache is a core extension distributed with PHP. | + | If the received path is a 'stream' |
- | Please explain how you have verified your RFC's compatibility with opcache. | + | If the returned value is non null, the path is cacheable. If it is null, the path is not cacheable. |
==== New Constants ==== | ==== New Constants ==== | ||
- | Describe any new constants so they can be accurately and comprehensively explained in the PHP documentation. | ||
- | ==== php.ini Defaults ==== | + | None |
- | If there are any php.ini settings then list: | + | |
- | * hardcoded default values | + | |
- | * php.ini-development values | + | |
- | * php.ini-production values | + | |
===== Open Issues ===== | ===== Open Issues ===== | ||
- | Make sure there are no open issues when the vote starts! | ||
- | ===== Unaffected PHP Functionality ===== | + | Discussion is under way to define how the cache can compute the key |
- | List existing areas/ | + | corresponding to a stream-wrapped path. |
- | This helps avoid any ambiguity, shows that you have thought deeply about the RFC's impact, and helps reduces mail list noise. | + | ===== Unaffected PHP Functionality ===== |
- | ===== Future Scope ===== | + | Stream wrappers that don't require their scripts to be cacheable |
- | This sections details areas where the feature might be improved in future, but that are not currently proposed | + | in any way. |
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | Include these so readers know where you are heading and can discuss the proposed voting options. | ||
- | State whether this project requires a 2/3 or 50%+1 majority (see [[voting]]) | + | Required majority: |
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | Links to any external patches and tests go here. | ||
- | If there is no patch, make it clear who will create a patch, or whether a volunteer to help with implementation is needed. | + | Pull Request: [[https:// |
- | Make it clear if the patch is intended to be the final patch, or is just a prototype. | + | This PR includes every modification described in this RFC, including phar and |
+ | plain files is_cacheable() handler. It also contains tests. | ||
+ | |||
+ | PHP documentation additions (file_is_cacheable(), | ||
+ | not written yet. | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | After the project is implemented, | ||
- | - the version(s) it was merged to | ||
- | - a link to the git commit(s) | ||
- | - a link to the PHP manual entry for the feature | ||
===== References ===== | ===== References ===== | ||
- | Links to external references, discussions or RFCs | + | |
+ | Pull request: [[https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== | ||
- | Keep this updated with features that were discussed on the mail lists. | + |
rfc/streams-is-cacheable.1420288762.txt.gz · Last modified: 2017/09/22 13:28 (external edit)