From d363047eb050e98cb9aad29bec11900ad5bbf329 Mon Sep 17 00:00:00 2001 From: moodler Date: Mon, 9 Feb 2004 12:27:34 +0000 Subject: [PATCH] TEXT CACHING ------------ I have a site which really needs this, so I went ahead with it already. This add-on will cache formatted texts in the database and use them for a specified timeperiod. By default it is disabled. Enable it with: $CFG->cachetext = 600; // in seconds --- config-dist.php | 8 ++++++++ lib/db/mysql.php | 11 +++++++++++ lib/db/mysql.sql | 17 +++++++++++++++++ lib/db/postgres7.php | 9 +++++++++ lib/db/postgres7.sql | 7 +++++++ version.php | 2 +- 6 files changed, 53 insertions(+), 1 deletion(-) diff --git a/config-dist.php b/config-dist.php index 82b89934d8..5bb7900011 100644 --- a/config-dist.php +++ b/config-dist.php @@ -154,6 +154,14 @@ $CFG->admin = 'admin'; // Prevent scheduled backups from operating (and hide the GUI for them) // Useful for webhost operators who have alternate methods of backups // $CFG->disablescheduledbackups = true; +// +// On busy sites that use filters (such as the glossary autolinking) this +// may help - it specifies time in seconds to keep copies of formatted texts. +// $CFG->cachetext = 600; +// It has some disadvantages: +// 1) Texts will take this long to regenerate, so changes to the glossary +// will not be evident immediately. +// 2) It won't work with filters that use user settings eg: multilang diff --git a/lib/db/mysql.php b/lib/db/mysql.php index 0dcdba842e..710672f4c8 100644 --- a/lib/db/mysql.php +++ b/lib/db/mysql.php @@ -643,6 +643,17 @@ function main_upgrade($oldversion=0) { table_column("course", "", "lang", "varchar", "5", "", "", "", "groupmodeforce"); } + if ($oldversion < 2004020902) { + modify_database("", "CREATE TABLE `prefix_text_cache` ( + `id` int(10) unsigned NOT NULL auto_increment, + `md5key` varchar(32) NOT NULL default '', + `formattedtext` longtext NOT NULL, + `timemodified` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `md5key` (`md5key`) + ) TYPE=MyISAM COMMENT='For storing temporary copies of processed texts';"); + } + return $result; } diff --git a/lib/db/mysql.sql b/lib/db/mysql.sql index c6c8f31625..651b38c7db 100644 --- a/lib/db/mysql.sql +++ b/lib/db/mysql.sql @@ -155,6 +155,23 @@ CREATE TABLE `prefix_event` ( KEY `courseid` (`courseid`), KEY `userid` (`userid`) ) TYPE=MyISAM COMMENT='For everything with a time associated to it'; +# -------------------------------------------------------- + +# +# Table structure for table `text_cache` +# + +CREATE TABLE `prefix_text_cache` ( + `id` int(10) unsigned NOT NULL auto_increment, + `md5key` varchar(32) NOT NULL default '', + `formattedtext` longtext NOT NULL, + `timemodified` int(10) unsigned NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `md5key` (`md5key`) +) TYPE=MyISAM COMMENT='For storing temporary copies of processed texts'; +# -------------------------------------------------------- + + # # Table structure for table `group` diff --git a/lib/db/postgres7.php b/lib/db/postgres7.php index ca4e8ef14b..173fa09a5b 100644 --- a/lib/db/postgres7.php +++ b/lib/db/postgres7.php @@ -389,6 +389,15 @@ function main_upgrade($oldversion=0) { table_column("course", "", "lang", "varchar", "5", "", "", "", "groupmodeforce"); } + if ($oldversion < 2004020902) { + modify_database("", "CREATE TABLE prefix_text_cache ( + id SERIAL PRIMARY KEY, + md5key varchar(32) NOT NULL default '', + formattedtext text, + timemodified integer NOT NULL default '0' + );"); + } + return $result; } diff --git a/lib/db/postgres7.sql b/lib/db/postgres7.sql index 99692a9c67..1a57c320db 100644 --- a/lib/db/postgres7.sql +++ b/lib/db/postgres7.sql @@ -165,6 +165,13 @@ CREATE TABLE prefix_scale ( timemodified integer NOT NULL default '0' ); +CREATE TABLE prefix_text_cache ( + id SERIAL PRIMARY KEY, + md5key varchar(32) NOT NULL default '', + formattedtext text, + timemodified integer NOT NULL default '0' +); + CREATE TABLE prefix_user ( id SERIAL PRIMARY KEY, confirmed integer NOT NULL default '0', diff --git a/version.php b/version.php index fff4621716..1637f4c9e3 100644 --- a/version.php +++ b/version.php @@ -5,7 +5,7 @@ // database to determine whether upgrades should // be performed (see lib/db/*.php) -$version = 2004020900; // The current version is a date (YYYYMMDDXX) +$version = 2004020902; // The current version is a date (YYYYMMDDXX) $release = "1.2 development"; // User-friendly version number -- 2.39.5