summaryrefslogtreecommitdiff
path: root/lib/Multi/Maintenance.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-03-08 12:20:02 +0100
committerYorhel <git@yorhel.nl>2009-03-08 12:20:02 +0100
commitbfd587563ae9fede8299bf97dfea1e07c2d4fefe (patch)
tree48de5e925de11577f983899c9ec747501160d98b /lib/Multi/Maintenance.pm
parent68ab69f9339741dd3a1f50dd5321e540e8361b88 (diff)
Added caching of tags_vn_bayesian and the VN count for tags
Updated hourly by Multi. May want to look for a better way to update this cache, because I'm afraid the current tags_vn_calc() is going to perform very badly on larger databases.
Diffstat (limited to 'lib/Multi/Maintenance.pm')
-rw-r--r--lib/Multi/Maintenance.pm17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm
index e9c9b337..10f02681 100644
--- a/lib/Multi/Maintenance.pm
+++ b/lib/Multi/Maintenance.pm
@@ -18,7 +18,7 @@ sub spawn {
my $p = shift;
POE::Session->create(
package_states => [
- $p => [qw| _start cmd_maintenance vncache usercache statscache revcache integrity unkanime logrotate vnpopularity |],
+ $p => [qw| _start cmd_maintenance vncache usercache statscache revcache integrity unkanime logrotate vnpopularity tagcache |],
],
);
}
@@ -26,8 +26,10 @@ sub spawn {
sub _start {
$_[KERNEL]->alias_set('maintenance');
- $_[KERNEL]->call(core => register => qr/^maintenance((?: (?:vncache|revcache|usercache|statscache|integrity|unkanime|logrotate|vnpopularity))+)$/, 'cmd_maintenance');
-
+ $_[KERNEL]->call(core => register => qr/^maintenance((?: (?:vncache|revcache|usercache|statscache|integrity|unkanime|logrotate|vnpopularity|tagcache))+)$/, 'cmd_maintenance');
+
+ # recalculate tag<->vn cache each hour (better do this once every 24 hours when the DB grows)
+ $_[KERNEL]->post(core => addcron => '0 * * * *', 'maintenance tagcache');
# Perform some maintenance functions every day on 0:00
$_[KERNEL]->post(core => addcron => '0 0 * * *', 'maintenance vncache integrity unkanime vnpopularity');
# update caches and rotate logs every 1st day of the month at 0:05
@@ -132,7 +134,7 @@ sub unkanime {
WHERE a.lastfetch < 0|);
$q->execute();
my $r = $q->fetchall_arrayref([]);
- my %aid = map {
+ my %aid = map {
my $a=$_;
$a->[1] => join(',', map { $a->[1] == $_->[1] ? $_->[0] : () } @$r)
} @$r;
@@ -177,6 +179,13 @@ sub vnpopularity {
}
+sub tagcache {
+ my $S = [gettimeofday];
+ $Multi::SQL->do(q|SELECT tag_vn_calc()|);
+ $_[KERNEL]->call(core => log => 3 => '(Re)calculated tags_vn_stored in %.2fs', tv_interval($S));
+}
+
+
1;