summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Object.pm
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2014-07-07 10:01:17 +0200
committerByron Jones <glob@mozilla.com>2014-07-07 10:01:17 +0200
commit2721de5aa6b81e069a44b05e8b8e44c904928301 (patch)
tree619c827f18dd32efee485a1bd8b95055e58c8c1e /Bugzilla/Object.pm
parent3f631ad59df2f086e8d8343401ab27082cba5478 (diff)
downloadbugzilla-2721de5aa6b81e069a44b05e8b8e44c904928301.tar.gz
bugzilla-2721de5aa6b81e069a44b05e8b8e44c904928301.tar.xz
Bug 1033955: backport bug 1028795 to bmo (pre-load all related bugs during show_bug initialisation)
Diffstat (limited to 'Bugzilla/Object.pm')
-rw-r--r--Bugzilla/Object.pm68
1 files changed, 68 insertions, 0 deletions
diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm
index e3e4ca229..8a7bba1c5 100644
--- a/Bugzilla/Object.pm
+++ b/Bugzilla/Object.pm
@@ -224,6 +224,22 @@ sub initialize {
# Provides a mechanism for objects to be cached in the request_cahce
+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) = @_;
@@ -1456,6 +1472,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