Set version to 5.20.beta1
[civicrm-core.git] / CRM / Utils / Cache / NaiveHasTrait.php
index 4c270b2bd9a3409e8fa9958af4ba2b421e7926ff..786e8c0d21a9e1be0ed2f6e603ebb3cc59d2f8fb 100644 (file)
  * 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);
   }
 
 }