AfformScanner - Just use the long cache
authorTim Otten <totten@civicrm.org>
Fri, 20 Dec 2019 07:53:13 +0000 (23:53 -0800)
committerCiviCRM <info@civicrm.org>
Wed, 16 Sep 2020 02:13:20 +0000 (19:13 -0700)
The long cache didn't exist when this class was first created, but it seems
better suited. #knockonwood

ext/afform/core/CRM/Afform/AfformScanner.php

index a6bce85418b236c134b9a8ae391222d0b89efbc2..ce7b96c6dc7912b13369d05bb7a884a48d120fff 100644 (file)
@@ -27,15 +27,7 @@ class CRM_Afform_AfformScanner {
    * CRM_Afform_AfformScanner constructor.
    */
   public function __construct() {
-    // TODO Manage this is a service, and inject the cache service.
-    $this->cache = new CRM_Utils_Cache_SqlGroup([
-      // Note: If there are edge-case bugs with multisite, consider changing
-      // the group key - but tread carefully to ensure that (eg) CLI+web workers
-      // see the same cache.
-      'group' => 'afform_scanner',
-      'prefetch' => FALSE,
-    ]);
-    // $this->cache = new CRM_Utils_Cache_Arraycache([]);
+    $this->cache = Civi::cache('long');
   }
 
   /**
@@ -47,7 +39,7 @@ class CRM_Afform_AfformScanner {
   public function findFilePaths() {
     if (!CRM_Core_Config::singleton()->debug) {
       // FIXME: Use a separate setting. Maybe use the asset-builder cache setting?
-      $paths = $this->cache->get('allPaths');
+      $paths = $this->cache->get('afformAllPaths');
       if ($paths !== NULL) {
         return $paths;
       }
@@ -70,7 +62,7 @@ class CRM_Afform_AfformScanner {
 
     $this->appendFilePaths($paths, $this->getSiteLocalPath(), 10);
 
-    $this->cache->set('allPaths', $paths);
+    $this->cache->set('afformAllPaths', $paths);
     return $paths;
   }
 
@@ -114,7 +106,7 @@ class CRM_Afform_AfformScanner {
   }
 
   public function clear() {
-    $this->cache->flush();
+    $this->cache->delete('afformAllPaths');
   }
 
   /**