From 99e02eab80679cb1ac4ede7c4d8054b8a2164bad Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Thu, 3 Jul 2014 15:36:08 +0800 Subject: Bug 1028795: pre-load all related bugs during show_bug initialisation r=sgreen,a=sgreen --- Bugzilla/Object.pm | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'Bugzilla/Object.pm') diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm index e5704b3b1..f20803632 100644 --- a/Bugzilla/Object.pm +++ b/Bugzilla/Object.pm @@ -196,6 +196,23 @@ sub initialize { } # Provides a mechanism for objects to be cached in the request_cache + +sub object_cache_get { + my ($class, $id) = @_; + return $class->_object_cache_get( + { id => $id, cache => 1}, + $class + ); +} + +sub object_cache_set { + my $self = shift; + return $self->_object_cache_set( + { id => $self->id, cache => 1 }, + $self + ); +} + sub _object_cache_get { my $class = shift; my ($param) = @_; @@ -1446,6 +1463,58 @@ Returns C<1> if the passed-in value is true, C<0> otherwise. =back +=head2 CACHE FUNCTIONS + +=over + +=item C + +=over + +=item B + +Class function which returns an object from the object-cache for the provided +C<$id>. + +=item B + +Takes an integer C<$id> of the object to retrieve. + +=item B + +Returns the object from the cache if found, otherwise returns C. + +=item B + +my $bug_from_cache = Bugzilla::Bug->object_cache_get(35); + +=back + +=item C + +=over + +=item B + +Object function which injects the object into the object-cache, using the +object's C as the key. + +=item B + +(none) + +=item B + +(nothing) + +=item B + +$bug->object_cache_set(); + +=back + +=back + =head1 CLASS FUNCTIONS =over -- cgit v1.2.3-24-g4f1b