Commit ebf0eb53 authored by totten's avatar totten

(#174) Update top-level interfaces to show PSR-16 support

parent 6c1c4ffc
......@@ -30,32 +30,14 @@
* @package CRM
* @copyright CiviCRM LLC (c) 2004-2018
*
* CRM_Utils_Cache_Interface
* CRM_Utils_Cache_Interface is a long-standing interface used within CiviCRM
* for interacting with a cache service. In style and substance, it is extremely
* similar to PHP-FIG's SimpleCache interface (PSR-16). Consequently, beginning
* with CiviCRM v5.4, this extends \Psr\SimpleCache\CacheInterface.
*
* PHP-FIG has been developing a draft standard for caching,
* PSR-6. The standard has not been ratified yet. When
* making changes to this interface, please take care to
* avoid *conflicst* with PSR-6's CacheItemPoolInterface. At
* time of writing, they do not conflict. Avoiding conflicts
* will enable more transition paths where Civi
* simultaneously supports both interfaces in the same
* implementation.
*
* For example, the current interface defines:
*
* function get($key) => mixed $value
*
* and PSR-6 defines:
*
* function getItem($key) => ItemInterface $item
*
* These are different styles (e.g. "weak item" vs "strong item"),
* but the two methods do not *conflict*. They can coexist,
* and you can trivially write adapters between the two.
*
* @see https://github.com/php-fig/fig-standards/blob/master/proposed/cache.md
* @see https://www.php-fig.org/psr/psr-16/
*/
interface CRM_Utils_Cache_Interface {
interface CRM_Utils_Cache_Interface extends \Psr\SimpleCache\CacheInterface {
/**
* Set the value in the cache.
......
......@@ -26,20 +26,15 @@ class Civi {
public static $statics = array();
/**
* EXPERIMENTAL. Retrieve a named cache instance.
*
* This interface is flagged as experimental due to political
* ambiguity in PHP community -- PHP-FIG has an open but
* somewhat controversial draft standard for caching. Based on
* the current draft, it's expected that this function could
* simultaneously support both CRM_Utils_Cache_Interface and
* PSR-6, but that depends on whether PSR-6 changes any more.
* Retrieve a named cache instance.
*
* @param string $name
* The name of the cache. The 'default' cache is biased toward
* high-performance caches (eg memcache/redis/apc) when
* available and falls back to single-request (static) caching.
* @return CRM_Utils_Cache_Interface
* NOTE: Beginning in CiviCRM v5.4, the cache instance complies with
* PSR-16 (\Psr\SimpleCache\CacheInterface).
*/
public static function cache($name = 'default') {
return \Civi\Core\Container::singleton()->get('cache.' . $name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment