From 920fa38fa645f1fb6da180061bdcd389038f645b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 23 Jan 2019 16:11:42 -0800 Subject: [PATCH] CRM_Core_BAO_Cache - Deprecate getItems(), getItem(), setItem(), deleteGroup() These interfaces predate PSR-16 -- which is more flexible and complete. PSR-16 supports TTLs, default-values, multi-key operations, etc. PSR-16 drivers can be extended/decorated/replaced. There are third-party implementations of PSR-16. And (personally) I find the code which consumes PSR-16 to be more readable+writeable (e.g. `$cache->get($key)` vs `CRM_Core_BAO_Cache::getItem($group, $item)`). However, `CRM_Core_BAO_Cache` has been around forever. I currently count ten distinct cache-groups which rely on it (5 from `civicrm-core` and 5 from `universe`). So we shouldn't remove it outright. --- CRM/Core/BAO/Cache.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CRM/Core/BAO/Cache.php b/CRM/Core/BAO/Cache.php index 43530d2f70..3fa207abf6 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -64,6 +64,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { * * @return object * The data if present in cache, else null + * @deprecated */ public static function &getItem($group, $path, $componentID = NULL) { if ($adapter = CRM_Utils_Constant::value('CIVICRM_BAO_CACHE_ADAPTER')) { @@ -105,6 +106,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { * * @return object * The data if present in cache, else null + * @deprecated */ public static function &getItems($group, $componentID = NULL) { if ($adapter = CRM_Utils_Constant::value('CIVICRM_BAO_CACHE_ADAPTER')) { @@ -150,6 +152,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { * (required) The path under which this item is stored. * @param int $componentID * The optional component ID (so componenets can share the same name space). + * @deprecated */ public static function setItem(&$data, $group, $path, $componentID = NULL) { if ($adapter = CRM_Utils_Constant::value('CIVICRM_BAO_CACHE_ADAPTER')) { @@ -221,6 +224,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { * @param string $path * Path of the item that needs to be deleted. * @param bool $clearAll clear all caches + * @deprecated */ public static function deleteGroup($group = NULL, $path = NULL, $clearAll = TRUE) { if ($adapter = CRM_Utils_Constant::value('CIVICRM_BAO_CACHE_ADAPTER')) { -- 2.25.1