Index: Drupal_Apache_Solr_Service.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/Attic/Drupal_Apache_Solr_Service.php,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 Drupal_Apache_Solr_Service.php
--- Drupal_Apache_Solr_Service.php	26 Nov 2008 13:35:27 -0000	1.1.2.3
+++ Drupal_Apache_Solr_Service.php	2 Dec 2008 18:52:08 -0000
@@ -3,7 +3,8 @@ require_once 'SolrPhpClient/Apache/Solr/
 
 class Drupal_Apache_Solr_Service extends Apache_Solr_Service {
 
-  var $luke;
+  protected $luke;
+  protected $luke_cid;
   const LUKE_SERVLET = 'admin/luke';
 
   /**
@@ -14,6 +15,7 @@ class Drupal_Apache_Solr_Service extends
     if (empty($this->luke[$num_terms])) {
       $url = $this->_constructUrl(self::LUKE_SERVLET, array('numTerms' => "$num_terms", 'wt' => self::SOLR_WRITER));
       $this->luke[$num_terms] = $this->_sendRawGet($url);
+      cache_set($this->luke_cid, $this->luke);
     }
   }
 
@@ -23,18 +25,41 @@ class Drupal_Apache_Solr_Service extends
 
   public function getLuke($num_terms = 0) {
     if (!isset($this->luke[$num_terms])) {
-        $this->setLuke($num_terms);
+      $this->setLuke($num_terms);
     }
     return $this->luke[$num_terms];
   }
 
   /**
+   * Clear cached Solr data.
+   */
+  public function clearCache() {
+    cache_clear_all("apachesolr:luke:", 'cache', TRUE);
+    $this->luke = array();
+  }
+
+  /**
+   * Clear the cache whenever we commit changes.
+   */
+  public function commit($optimize = TRUE, $waitFlush = TRUE, $waitSearcher = TRUE, $timeout = 3600) {
+    parent::commit($optimize, $waitFlush, $waitSearcher, $timeout);
+    $this->clearCache();
+  }
+
+  /**
    * Construct the Full URLs for the three servlets we reference
    */
-  protected function _initUrls()
-  {
+  protected function _initUrls() {
     parent::_initUrls();
     $this->_lukeUrl = $this->_constructUrl(self::LUKE_SERVLET, array('numTerms' => '0', 'wt' => self::SOLR_WRITER));
   }
 
+  public function __construct($host = 'localhost', $port = 8180, $path = '/solr/') {
+    parent::__construct($host, $port, $path);
+    $this->luke_cid = "apachesolr:luke:$host:$port:$path";
+    $cache = cache_get($this->luke_cid);
+    if (isset($cache->data)) {
+      $this->luke = $cache->data;
+    }
+  }
 }
