CRM_Core_BAO_Cache - Deprecate getItems(), getItem(), setItem(), deleteGroup()
authorTim Otten <totten@civicrm.org>
Thu, 24 Jan 2019 00:11:42 +0000 (16:11 -0800)
committerTim Otten <totten@civicrm.org>
Wed, 30 Jan 2019 02:53:11 +0000 (18:53 -0800)
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

index 43530d2f702b00e8cd837f952c0afe5c95d667b0..3fa207abf65984ebdcb9ae6f7ef12c626151a97e 100644 (file)
@@ -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')) {