Forráskód Böngészése

Added a cache clear when the OBO loader is run and when term are edited

Stephen Ficklin 6 éve
szülő
commit
401cfd1f02

+ 5 - 2
tripal_chado/includes/TripalImporter/OBOImporter.inc

@@ -575,8 +575,11 @@ class OBOImporter extends TripalImporter {
    *
    */
   public function postRun() {
+    
+    // Clear the cached terms
+    cache_clear_all('tripal_chado:term:*', 'cache', TRUE);
 
-    // Update the cv_root_mview materiailzed view.
+    // Update the cv_root_mview materialized view.
     $this->logMessage("Updating the cv_root_mview materialized view...");
     $mview_id = tripal_get_mview_id('cv_root_mview');
     tripal_populate_mview($mview_id);
@@ -585,7 +588,7 @@ class OBOImporter extends TripalImporter {
     $mview_id = tripal_get_mview_id('db2cv_mview');
     tripal_populate_mview($mview_id);
 
-    // Upate the cvtermpath table for each newly added CV.
+    // Update the cvtermpath table for each newly added CV.
     $this->logMessage("Updating cvtermpath table.  This may take a while...");
     foreach ($this->obo_namespaces as $namespace => $cv_id) {
       $this->logMessage("- Loading paths for vocabulary: @vocab", array('@vocab' => $namespace));

+ 4 - 0
tripal_chado/includes/tripal_chado.cv.inc

@@ -154,6 +154,10 @@ function tripal_cv_cv_edit_form_submit($form, &$form_state) {
   if (strcmp($op, 'Update')==0) {
     $match = array('cv_id' => $cv_id);
     $success = chado_update_record('cv', $match, $values);
+    
+    // Clear the cached terms
+    cache_clear_all('tripal_chado:term:*', 'cache', TRUE);
+    
     if ($success) {
       drupal_set_message(t("Controlled vocabulary updated"));
       drupal_goto('admin/tripal/loaders/chado_vocabs/chado_cvs');

+ 5 - 3
tripal_chado/includes/tripal_chado.vocab_storage.inc

@@ -257,9 +257,11 @@ function tripal_chado_vocab_get_term_children($vocabulary, $accession) {
  * This hook is created by the Tripal module and is not a Drupal hook.
  */
 function tripal_chado_vocab_get_term($vocabulary, $accession) {
+  // Cache ID for this term:
+  $cid = 'tripal_chado:term:' . $vocabulary . ':' . $accession;
   
-  // Check the cache fisrt. Get the term from cache if it's available
-  $cache = cache_get('tripal_chado:term:' . $vocabulary . ':' . $accession);
+  // Check the cache first. Get the term from cache if it's available
+  $cache = cache_get($cid, 'cache');
   if (isset($cache->data)) {
     return $cache->data;
   }
@@ -292,7 +294,7 @@ function tripal_chado_vocab_get_term($vocabulary, $accession) {
 
   // Cache the term to reduce the amount of queries sent to the database
   $term =  _tripal_chado_format_term_description($cvterm);
-  cache_set('tripal_chado:term:' . $vocabulary . ':' . $accession, $term);
+  cache_set($cid, $term, 'cache', CACHE_TEMPORARY);
   return $term;
 }