From a11f4823342225b2dbe8b931b90d8d14ba80a236 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Thu, 19 Dec 2013 13:44:01 +0800 Subject: Bug 237498: Add memcached integration r=dkl, a=sgreen --- Bugzilla.pm | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 11 deletions(-) (limited to 'Bugzilla.pm') diff --git a/Bugzilla.pm b/Bugzilla.pm index 24963858e..99fcbed46 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -19,23 +19,24 @@ BEGIN { } } -use Bugzilla::Config; -use Bugzilla::Constants; use Bugzilla::Auth; use Bugzilla::Auth::Persist::Cookie; use Bugzilla::CGI; -use Bugzilla::Extension; +use Bugzilla::Config; +use Bugzilla::Constants; use Bugzilla::DB; +use Bugzilla::Error; +use Bugzilla::Extension; +use Bugzilla::Field; +use Bugzilla::Flag; use Bugzilla::Install::Localconfig qw(read_localconfig); use Bugzilla::Install::Requirements qw(OPTIONAL_MODULES); use Bugzilla::Install::Util qw(init_console include_languages); +use Bugzilla::Memcached; use Bugzilla::Template; +use Bugzilla::Token; use Bugzilla::User; -use Bugzilla::Error; use Bugzilla::Util; -use Bugzilla::Field; -use Bugzilla::Flag; -use Bugzilla::Token; use File::Basename; use File::Spec::Functions; @@ -641,6 +642,12 @@ sub process_cache { return $_process_cache; } +# This is a memcached wrapper, which provides cross-process and cross-system +# caching. +sub memcached { + return $_[0]->process_cache->{memcached} ||= Bugzilla::Memcached->_new(); +} + # Private methods # Per-process cleanup. Note that this is a plain subroutine, not a method, @@ -949,17 +956,89 @@ this Bugzilla installation. Tells you whether or not a specific feature is enabled. For names of features, see C in C. +=back + +=head1 B + +Bugzilla has several different caches available which provide different +capabilities and lifetimes. + +The keys of all caches are unregulated; use of prefixes is suggested to avoid +collisions. + +=over + +=item B + +The request cache is a hashref which supports caching any perl variable for the +duration of the current request. At the end of the current request the contents +of this cache are cleared. + +Examples of its use include caching objects to avoid re-fetching the same data +from the database, and passing data between otherwise unconnected parts of +Bugzilla. + +=over + +=item C + +Returns a hashref which can be checked and modified to store any perl variable +for the duration of the current request. + =item C Removes all entries from the C. =back -=head1 B +=item B + +The process cache is a hashref which support caching of any perl variable. If +Bugzilla is configured to run using Apache mod_perl, the contents of this cache +are persisted across requests for the lifetime of the Apache worker process +(which varies depending on the SizeLimit configuration in mod_perl.pl). + +If Bugzilla isn't running under mod_perl, the process cache's contents are +cleared at the end of the request. + +The process cache is only suitable for items which never change while Bugzilla +is running (for example the path where Bugzilla is installed). =over -=item process_cache +=item C + +Returns a hashref which can be checked and modified to store any perl variable +for the duration of the current process (mod_perl) or request (mod_cgi). + +=back + +=item B + +If Memcached is installed and configured, Bugzilla can use it to cache data +across requests and between webheads. Unlike the request and process caches, +only scalars, hashrefs, and arrayrefs can be stored in Memcached. + +Memcached integration is only required for large installations of Bugzilla -- if +you have multiple webheads then configuring Memcached is recommended. + +=over + +=item C + +Returns a C object. An object is always returned even if +Memcached is not available. + +See the documentation for the C module for more +information. + +=back + +=back + +=head1 B + +=over =item init_page @@ -971,8 +1050,6 @@ Removes all entries from the C. =item active_custom_fields -=item request_cache - =item has_flags =back -- cgit v1.2.3-24-g4f1b