Fix for ticket #1027: Add index on cache key column.

(and fix the packager to truncate the cache table before packaging)
This commit is contained in:
Andy Staudacher
2010-02-22 00:30:54 -08:00
parent 95374070db
commit 6ce0132842
4 changed files with 15 additions and 3 deletions

View File

@@ -42,6 +42,7 @@ CREATE TABLE {caches} (
`expiration` int(9) NOT NULL,
`cache` longblob,
PRIMARY KEY (`id`),
KEY `key` (`key`),
KEY `tags` (`tags`)
) DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
@@ -239,7 +240,7 @@ CREATE TABLE {modules} (
UNIQUE KEY `name` (`name`)
) AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
SET character_set_client = @saved_cs_client;
INSERT INTO {modules} VALUES (1,1,'gallery',29);
INSERT INTO {modules} VALUES (1,1,'gallery',30);
INSERT INTO {modules} VALUES (2,1,'user',3);
INSERT INTO {modules} VALUES (3,1,'comment',2);
INSERT INTO {modules} VALUES (4,1,'organize',1);

View File

@@ -82,6 +82,7 @@ class Packager_Controller extends Controller {
module::set_var("gallery", "blocks_{$key}", serialize($blocks));
}
Database::instance()->query("TRUNCATE {caches}");
Database::instance()->query("TRUNCATE {sessions}");
Database::instance()->query("TRUNCATE {logs}");
db::build()

View File

@@ -32,6 +32,10 @@ class gallery_installer {
PRIMARY KEY (`id`))
DEFAULT CHARSET=utf8;");
// Using a simple index instead of a unique key for the
// key column to avoid handling of concurrency issues
// on insert. Thus allowing concurrent inserts on the
// same cache key, as does Memcache / xcache.
$db->query("CREATE TABLE {caches} (
`id` int(9) NOT NULL auto_increment,
`key` varchar(255) NOT NULL,
@@ -39,6 +43,7 @@ class gallery_installer {
`expiration` int(9) NOT NULL,
`cache` longblob,
PRIMARY KEY (`id`),
KEY (`key`),
KEY (`tags`))
DEFAULT CHARSET=utf8;");
@@ -290,7 +295,7 @@ class gallery_installer {
module::set_var("gallery", "credits", (string) $powered_by_string);
module::set_var("gallery", "simultaneous_upload_limit", 5);
module::set_var("gallery", "admin_area_timeout", 90 * 60);
module::set_version("gallery", 29);
module::set_version("gallery", 30);
}
static function upgrade($version) {
@@ -545,6 +550,11 @@ class gallery_installer {
module::set_var("gallery", "credits", "Powered by <a href=\"%url\">%gallery_version</a>");
module::set_version("gallery", $version = 29);
}
if ($version == 29) {
$db->query("ALTER TABLE {caches} ADD KEY (`key`);");
module::set_version("gallery", $version = 30);
}
}
static function uninstall() {

View File

@@ -1,3 +1,3 @@
name = "Gallery 3"
description = "Gallery core application"
version = 29
version = 30