summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Object.pm
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-07-03 09:36:08 +0200
committerByron Jones <glob@mozilla.com>2014-07-03 09:36:08 +0200
commit99e02eab80679cb1ac4ede7c4d8054b8a2164bad (patch)
tree6b406d68f5f9c0a260f44366b9ecf4d2b2604586 /Bugzilla/Object.pm
parenta26d34af37d00485846cdf3978b726824f6138d4 (diff)
downloadbugzilla-99e02eab80679cb1ac4ede7c4d8054b8a2164bad.tar.gz
bugzilla-99e02eab80679cb1ac4ede7c4d8054b8a2164bad.tar.xz
Bug 1028795: pre-load all related bugs during show_bug initialisation
r=sgreen,a=sgreen
Diffstat (limited to 'Bugzilla/Object.pm')
-rw-r--r--Bugzilla/Object.pm69
1 files changed, 69 insertions, 0 deletions
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<object_cache_get>
+
+=over
+
+=item B<Description>
+
+Class function which returns an object from the object-cache for the provided
+C<$id>.
+
+=item B<Params>
+
+Takes an integer C<$id> of the object to retrieve.
+
+=item B<Returns>
+
+Returns the object from the cache if found, otherwise returns C<undef>.
+
+=item B<Example>
+
+my $bug_from_cache = Bugzilla::Bug->object_cache_get(35);
+
+=back
+
+=item C<object_cache_set>
+
+=over
+
+=item B<Description>
+
+Object function which injects the object into the object-cache, using the
+object's C<id> as the key.
+
+=item B<Params>
+
+(none)
+
+=item B<Returns>
+
+(nothing)
+
+=item B<Example>
+
+$bug->object_cache_set();
+
+=back
+
+=back
+
=head1 CLASS FUNCTIONS
=over