Add a method to clear cache.
Patch by kareila.
diffs (59 lines):
diff -r e98efcb4f346 -r f1179dab51c0 cgi-bin/DW/Mood.pm
--- a/cgi-bin/DW/Mood.pm Thu Jun 17 15:05:20 2010 +0800
+++ b/cgi-bin/DW/Mood.pm Thu Jun 17 15:30:06 2010 +0800
@@ -208,4 +208,19 @@ sub get_external_moodid {
return $external_moodid ? $external_moodid : 0;
}
+# clear cached theme data from memory
+# arguments: theme id (only required if called as class method)
+# returns: nothing
+sub clear_cache {
+ my ( $self, $themeid ) = @_;
+
+ # load theme id from object if needed
+ $themeid ||= $self->id if ref $self;
+
+ # clear the caches
+ LJ::MemCache::delete( [$themeid, "moodthemedata:$themeid"] );
+ delete $LJ::CACHE_MOOD_THEME{$themeid};
+}
+
+
1;
diff -r e98efcb4f346 -r f1179dab51c0
cgi-bin/LJ/Console/Command/MoodthemeSetpic.pm
--- a/cgi-bin/LJ/Console/Command/MoodthemeSetpic.pm Thu Jun 17 15:05:20
2010 +0800
+++ b/cgi-bin/LJ/Console/Command/MoodthemeSetpic.pm Thu Jun 17 15:30:06
2010 +0800
@@ -69,8 +69,7 @@ sub execute {
$self->error("Database error: " . $dbh->errstr)
if $dbh->err;
- delete $LJ::CACHE_MOOD_THEME{$themeid};
- LJ::MemCache::delete([$themeid, "moodthemedata:$themeid"]);
+ DW::Mood->clear_cache( $themeid );
return 1;
}
diff -r e98efcb4f346 -r f1179dab51c0 htdocs/manage/moodthemes.bml
--- a/htdocs/manage/moodthemes.bml Thu Jun 17 15:05:20 2010 +0800
+++ b/htdocs/manage/moodthemes.bml Thu Jun 17 15:30:06 2010 +0800
@@ -391,15 +391,13 @@ body<=
my $i = $dbh->do("REPLACE INTO moodthemedata (moodthemeid,
moodid, " .
"picurl, width, height) VALUES $bind", undef,
@repl_values);
return "<?h1 $ML{'Error'} h1?><?p
$ML{'.error.cantupdatetheme'} p?>" unless $i;
- }
+ }
# Kill any memcache data about this moodtheme
- LJ::MemCache::delete([$themeid, "moodthemedata:$themeid"]);
+ DW::Mood->clear_cache( $themeid );
- delete $LJ::CACHE_MOOD_THEME{$themeid};
-
- $ret .= "<br />$ML{'.saved'}<br /><br />\n";
- return BML::redirect($self_uri);
+ $ret .= "<br />$ML{'.saved'}<br /><br />\n";
+ return BML::redirect( $self_uri );
}
$ret .= BML::ml('Backlink', {
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog