From 0f2dd8d714a424cf383d925f8b55a098716b0660 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Wed, 2 Sep 2015 13:41:48 +0800 Subject: Bug 1199136 - lower memory consumption to better operate in bugzilladm's low memory environment --- Bugzilla/Object.pm | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'Bugzilla/Object.pm') diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm index 2349b57e6..84d384d2b 100644 --- a/Bugzilla/Object.pm +++ b/Bugzilla/Object.pm @@ -276,6 +276,16 @@ sub object_cache_key { } } +sub object_cache_clearall { + my $class = shift; + my $cache = Bugzilla->request_cache; + $class = blessed($class) if blessed($class); + my $prefix = $class . ','; + foreach my $key (grep { substr($_, 0, length($prefix)) eq $prefix } keys %$cache) { + delete $cache->{$key}; + } +} + # To support serialisation, we need to capture the keys in an object's default # hashref. sub _serialisation_keys { @@ -1526,6 +1536,28 @@ $bug->object_cache_set(); =back +=item C + +=over + +=item B + +Removes all objects for the specified class from the cache. + +=item B + +(none) + +=item B + +(nothing) + +=item B + +Bugzilla::User->object_cache_clearall(); + +=back + =back =head1 CLASS FUNCTIONS -- cgit v1.2.3-24-g4f1b