rfc:streams-is-cacheable

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
rfc:streams-is-cacheable [2015/01/03 12:39] – created francoisrfc: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: 0.+  * 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: Draft+  * Status: Under discussion
   * First Published at: http://wiki.php.net/rfc/streams-is-cacheable   * First Published at: http://wiki.php.net/rfc/streams-is-cacheable
- 
  
 ===== Introduction ===== ===== Introduction =====
Line 14: Line 13:
 ===== Proposal ===== ===== Proposal =====
  
-All the features and examples of the proposal.+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, the system looses a great 
 +part of its value.
  
-To [[http://news.php.net/php.internals/66051|paraphrase Zeev Suraski]]explain hows the proposal brings substantial value to be considered +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 as opcode-cacheable (APC), whatever wrapper it is coming from, or 
 +a list of 'cacheable' protocols is declared explicitely in the cache code. For 
 +instance, opcache 
 +is using the second solution : 'file' and 'phar' are explicitely 
 +declared as the only 'cacheable' stream wrappers. This is a 
 +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 'stream_is_cacheable' is added at the end of the php_stream_wrapper_ops 
 +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 'stream_is_cacheable' element is null, every URI for this wrapper 
 +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 [,options]). 
 +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, a new PHP function named file_is_cacheable(path [, options [, context]]) 
 +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.+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 always returns 1.+Phar needs to implement an is_cacheable() function, returning always 1
 + 
 +The same for the plain files wrapper.
  
 ==== To Opcache ==== ==== To Opcache ====
  
-Opcode caches will implement the following logic : +Opcode caches must implement the following logic : 
-TODO + 
-It is necessary to develop RFC's with opcache in mindsince opcache is a core extension distributed with PHP.+If the received path is 'stream' pathcall php_stream_is_cacheable(path, 0, NULL).
  
-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/features of PHP that will not be changed by the RFC.+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 are not modified 
-This sections details areas where the feature might be improved in future, but that are not currently proposed in this RFC.+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: 50%+1
  
 ===== 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://github.com/php/php-src/pull/976]]
  
-Make it clear if the patch is intended to be the final patchor is just a prototype.+This PR includes every modification described in this RFCincluding phar and 
 +plain files is_cacheable() handler. It also contains tests. 
 + 
 +PHP documentation additions (file_is_cacheable(), streamWrapper::is_cacheable()) 
 +not written yet.
  
 ===== Implementation ===== ===== Implementation =====
-After the project is implemented, this section should contain  
-  - 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://github.com/php/php-src/pull/976]]
  
 ===== 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)