? boost-453426.1.patch
? boost-453426.patch
? boost.patch
Index: boost.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.admin.inc,v
retrieving revision 1.1.2.1.2.3.2.29
diff -u -p -r1.1.2.1.2.3.2.29 boost.admin.inc
--- boost.admin.inc	13 Jun 2009 10:14:16 -0000	1.1.2.1.2.3.2.29
+++ boost.admin.inc	14 Jun 2009 09:33:13 -0000
@@ -45,7 +45,7 @@ function boost_admin_settings($form = ar
     '#title' => t('Boost - Default minimum cache lifetime'),
     '#default_value' => BOOST_CACHE_LIFETIME,
     '#options' => $period,
-    '#description' => t('The minimum cache lifetime is the minimum amount of time that will elapse before the cache is emptied. Cache lifetime gets checked on cron runs.'),
+    '#description' => t('The minimum cache lifetime is the minimum amount of time that will elapse before the cache is emptied. Cache lifetime gets checked on cron runs. <br /> %count pages cached with boost.', array('%count' => boost_count_db())),
     '#weight'        => -9,
   );
   $form['cache'] = array(
@@ -56,8 +56,14 @@ function boost_admin_settings($form = ar
     '#description'    => t("If boost can not or will not cache the page, then the database will try to cache it. If boost can cache the page then it will not appear in the database cache. This is the standard Drupal cache.") . $description,
     '#weight'         => -5,
   );
-  $form['cache_lifetime']['#title'] = t('Core - Default minimum cache lifetime');
-  $form['cache_lifetime']['#options'] = $period;
+  $form['cache_lifetime'] = array(
+    '#type' => 'select',
+    '#title' => t('Core - Default minimum cache lifetime'),
+    '#default_value' => variable_get('cache_lifetime', 0),
+    '#options' => $period,
+    '#description' => t('On high-traffic sites, it may be necessary to enforce a minimum cache lifetime. The minimum cache lifetime is the minimum amount of time that will elapse before the cache is emptied and recreated, and is applied to both page and block caches. A larger minimum cache lifetime offers better performance, but users will not see new content for a longer period of time.<br /> %count pages cached with core.', array('%count' => boost_count_core_db())),
+  );
+
 
   // Cacheability settings
   // TODO: update to use Drupal 6.x core code.
Index: boost.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.install,v
retrieving revision 1.2.2.1.2.3.2.12
diff -u -p -r1.2.2.1.2.3.2.12 boost.install
--- boost.install	13 Jun 2009 10:14:16 -0000	1.2.2.1.2.3.2.12
+++ boost.install	14 Jun 2009 09:33:13 -0000
@@ -37,6 +37,8 @@ function boost_disable() {
 function boost_install() {
   // Ensure that the module is loaded early in the bootstrap:
   db_query("UPDATE {system} SET weight = -90 WHERE name = '%s'", 'boost');
+  // Create tables.
+  drupal_install_schema('boost');
 }
 
 /**
@@ -45,6 +47,8 @@ function boost_install() {
 function boost_uninstall() {
   db_query("DELETE FROM {variable} WHERE name LIKE '%s_%%'", 'boost');
   cache_clear_all('variables', 'cache');
+  // Delete tables.
+  drupal_uninstall_schema('boost');
 }
 
 /**
@@ -102,3 +106,57 @@ function boost_requirements($phase) {
   }
   return $requirements;
 }
+
+/**
+ * Implementation of hook_schema().
+ */
+function boost_schema() {
+  $schema['boost_cache'] = array(
+    'description' => t('Table for the list of the cached page'),
+    'fields' => array(
+      'filename' => array(
+        'description' => 'Path of the cached file relative to Drupal root.',
+        'type' => 'varchar',
+        'length' => 255,
+        'not null' => TRUE,
+        'default' => '',
+      ),
+      'expire' => array(
+        'description' => t('UNIX timestamp for the expiration date of cached page.'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'lifetime' => array(
+        'description' => t('Number of seconds this page should be considered fresh. Used to set the expiration column.'),
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+      ),
+      'push' => array(
+        'description' => 'A flag to indicate whether page should be crawled so it is fresh in the cache.',
+        'type' => 'int',
+        'size' => 'small',
+        'not null' => TRUE,
+        'default' => 1,
+      ),
+    ),
+    'indexes' => array(
+      'filename' => array('filename'),
+      'expire' => array('expire'),
+      'push' => array('push'),
+    ),
+    'primary key' => array('filename'),
+  );
+  return $schema;
+}
+
+/**
+ * Update 6100 - Install Boost Database.
+ */
+function boost_update_6100() {
+  // Create tables.
+  return drupal_install_schema('boost');
+}
\ No newline at end of file
Index: boost.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/boost/boost.module,v
retrieving revision 1.3.2.2.2.5.2.55
diff -u -p -r1.3.2.2.2.5.2.55 boost.module
--- boost.module	13 Jun 2009 10:14:16 -0000	1.3.2.2.2.5.2.55
+++ boost.module	14 Jun 2009 09:33:14 -0000
@@ -192,7 +192,7 @@ function boost_form_alter(&$form, $form_
 function boost_cron() {
   if (!BOOST_ENABLED) return;
 
-  if (variable_get('boost_expire_cron', TRUE) && boost_cache_expire_all()) {
+  if (variable_get('boost_expire_cron', TRUE) && boost_cache_db_expire()) {
     watchdog('boost', 'Expired stale files from static page cache.', array(), WATCHDOG_NOTICE);
   }
 }
@@ -506,12 +506,14 @@ function boost_is_cached($path) {
  * Deletes all files currently in the cache.
  */
 function boost_cache_clear_all() {
+  boost_cache_clear_all_db();
   boost_cache_delete(TRUE);
   watchdog('boost', 'Flushed ALL files from static page cache.', array(), WATCHDOG_NOTICE);
 }
 
 /**
  * Deletes all expired static files currently in the cache.
+ * OLD FUNCTION
  */
 function boost_cache_expire_all() {
   boost_cache_delete(FALSE);
@@ -519,6 +521,14 @@ function boost_cache_expire_all() {
 }
 
 /**
+ * Resets all entries in database.
+ */
+function boost_cache_clear_all_db() {
+  //db_query("DELETE FROM {boost_cache}");
+  db_query("UPDATE {boost_cache} SET expire = %d", 0);
+}
+
+/**
  * Deletes files in the cache.
  */
 function boost_cache_delete($flush = FALSE) {
@@ -607,6 +617,21 @@ function boost_cache_kill($filename) {
 }
 
 /**
+ * Flushes all expired pages from database
+ */
+function boost_cache_db_expire() {
+  $result = db_query('SELECT filename FROM {boost_cache} WHERE expire BETWEEN 1 AND %d', BOOST_TIME);
+  while ($boost = db_fetch_array($result)) {
+    boost_put_db($boost['filename'], 0);
+    boost_cache_kill($boost['filename']);
+  }
+  if (BOOST_FLUSH_DIR) {
+    //TO-DO: del empty dirs.
+  }
+  return TRUE;
+}
+
+/**
  * Returns the cached contents of the specified page, if available.
  */
 function boost_cache_get($path) {
@@ -649,12 +674,42 @@ function boost_cache_set($path, $data = 
     if (BOOST_GZIP) {
       boost_cache_write(str_replace(BOOST_FILE_PATH, BOOST_GZIP_FILE_PATH, $filename) . '.gz', gzencode($data, 9));
     }
+    boost_put_db($filename, BOOST_CACHE_LIFETIME + BOOST_TIME);
   }
 
   return TRUE;
 }
 
 /**
+ * Puts the expiration time in the database.
+ */
+function boost_put_db($filename, $expire, $lifetime = BOOST_CACHE_LIFETIME, $push = 1) {
+  db_query("UPDATE {boost_cache} SET expire = %d, lifetime = %d, push = %d WHERE filename = '%s'", $expire, $lifetime, $push, $filename);
+  if (!db_affected_rows()) {
+    @db_query("INSERT INTO {boost_cache} (filename, expire, lifetime, push) VALUES ('%s', %d, %d, %d)", $filename, $expire, $lifetime, $push);
+  }
+}
+
+/**
+ * Counts the number of pages in the static cache.
+ */
+function boost_count_db($all = FALSE) {
+  if ($all) {
+    return db_result(db_query("SELECT COUNT(*) FROM {boost_cache}"));
+  }
+  else {
+    return db_result(db_query("SELECT COUNT(*) FROM {boost_cache} WHERE expire <> 0"));
+  }
+}
+
+/**
+ * Counts the number of pages in the core cache.
+ */
+function boost_count_core_db($all = FALSE) {
+  return db_result(db_query("SELECT COUNT(*) FROM {cache_page}"));
+}
+
+/**
  * Writes data to filename in an atomic operation thats compatible with older
  * versions of php (php < 5.2.4 file_put_contents() doesn't lock correctly).
  */
