rfc:streams-is-cacheable
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:streams-is-cacheable [2015/01/04 01:40] – reflowed text ajf | 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: 1.0 | + | * Version: 1.2 |
- | * Date: 2015-01-04 | + | * Date: 2015-01-04 |
* Author: François Laupretre, francois@tekwire.net | * Author: François Laupretre, francois@tekwire.net | ||
* Status: Under discussion | * Status: Under discussion | ||
Line 25: | Line 25: | ||
instance, opcache | instance, opcache | ||
is using the second solution : ' | is using the second solution : ' | ||
- | declared as the only ' | + | declared as the only ' |
- | quick-and-dirty workaround and we now | + | quick-and-dirty workaround and there is real need for a reliable and generic |
- | need a reliable and generic way of determining whether an URI is cacheable. | + | way of determining whether an URI is cacheable. |
What I am proposing : | 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 45: | Line 56: | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
- | 5.7, if released. Otherwise, | + | PHP 7. |
===== RFC Impact ===== | ===== RFC Impact ===== | ||
Line 54: | 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. | The same for the plain files wrapper. | ||
Line 60: | Line 71: | ||
==== To Opcache ==== | ==== To Opcache ==== | ||
- | Opcode caches | + | Opcode caches |
If the received path is a ' | If the received path is a ' | ||
Line 68: | Line 79: | ||
==== New Constants ==== | ==== New Constants ==== | ||
- | The C-level PHP_STREAMS_SUPPORT_IS_CACHEABLE is defined. This allows conditional | + | None |
- | code using '# | + | |
===== Open Issues ===== | ===== Open Issues ===== | ||
- | None | + | Discussion is under way to define how the cache can compute the key |
+ | corresponding to a stream-wrapped path. | ||
===== Unaffected PHP Functionality ===== | ===== Unaffected PHP Functionality ===== | ||
Line 82: | Line 93: | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
- | 2/3 or 50%+1 majority ? Not clear for me :) | + | Required majority: |
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
- | A pull request is available at : | + | Pull Request: [[https:// |
- | + | ||
- | [[https:// | + | |
- | This patch includes every modification described in this RFC, including phar and | + | This PR includes every modification described in this RFC, including phar and |
plain files is_cacheable() handler. It also contains tests. | plain files is_cacheable() handler. It also contains tests. | ||
- | PHP manual changes | + | PHP documentation additions (file_is_cacheable(), |
+ | not written yet. | ||
===== Implementation ===== | ===== Implementation ===== |
rfc/streams-is-cacheable.1420335635.txt.gz · Last modified: 2017/09/22 13:28 (external edit)