Set version to 5.20.beta1
[civicrm-core.git] / CRM / Utils / Cache / NaiveHasTrait.php
index 78ecc678876373ff384fea8a29a8aac08d5560df..786e8c0d21a9e1be0ed2f6e603ebb3cc59d2f8fb 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | CiviCRM version 5                                                  |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018                                |
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
 /**
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
  *
  * The traditional CRM_Utils_Cache_Interface did not support has().
  * To get drop-in compliance with PSR-16, we use a naive adapter.
  *
- * Ideally, these should be replaced with more performant/native versions.
+ * There may be opportunities to replace/optimize in specific drivers.
  */
 trait CRM_Utils_Cache_NaiveHasTrait {
 
   public function has($key) {
-    // This is crazy-talk. If you've got an environment setup where you might
-    // be investigating this, fix your preferred cache driver by
-    // replacing `NaiveHasTrait` with a decent function.
-    $hasDefaultA = ($this->get($key, NULL) === NULL);
-    $hasDefaultB = ($this->get($key, 123) === 123);
-    return !($hasDefaultA && $hasDefaultB);
+    $nack = CRM_Utils_Cache::nack();
+    $value = $this->get($key, $nack);
+    return ($value !== $nack);
   }
 
 }