3 * Functions to get cache objects.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 use MediaWiki\MediaWikiServices
;
25 use Wikimedia\ObjectCache\BagOStuff
;
28 * @see ObjectCacheFactory
33 * @deprecated since 1.43; use ObjectCacheFactory instead.
34 * @var BagOStuff[] Map of (id => BagOStuff)
36 public static $instances = [];
39 * Get a cached instance of the specified type of cache object.
41 * @deprecated since 1.43; use ObjectCacheFactory::getInstance instead.
43 * @param string|int $id A key in $wgObjectCaches.
46 public static function getInstance( $id ) {
47 return MediaWikiServices
::getInstance()->getObjectCacheFactory()->getInstance( $id );
51 * @see ObjectCacheFactory::newFromParams()
53 * @deprecated since 1.42, Use ObjectCacheFactory::newFromParams instead.
54 * @param array $params
58 public static function newFromParams( array $params ) {
59 return MediaWikiServices
::getInstance()->getObjectCacheFactory()
60 ->newFromParams( $params );
64 * Factory function for CACHE_ANYTHING (referenced by configuration)
66 * CACHE_ANYTHING means that stuff has to be cached, not caching is not an option.
67 * If a caching method is configured for any of the main caches ($wgMainCacheType,
68 * $wgMessageCacheType, $wgParserCacheType), then CACHE_ANYTHING will effectively
69 * be an alias to the configured cache choice for that.
70 * If no cache choice is configured (by default $wgMainCacheType is CACHE_NONE),
71 * then CACHE_ANYTHING will forward to CACHE_DB.
73 * @deprecated since 1.42, Use ObjectCacheFactory::getInstance( CACHE_ANYTHING );
77 public static function newAnything() {
78 return MediaWikiServices
::getInstance()->getObjectCacheFactory()
79 ->getInstance( CACHE_ANYTHING
);
83 * @deprecated since 1.42, Use ObjectCacheFactory::getLocalServerInstance()
84 * @param int|string|array $fallback Fallback cache or parameter map with 'fallback'
88 public static function getLocalServerInstance( $fallback = CACHE_NONE
) {
89 return MediaWikiServices
::getInstance()->getObjectCacheFactory()
90 ->getLocalServerInstance( $fallback );
94 * Get the main cluster-local cache object.
96 * @deprecated since 1.43, Use ObjectCacheFactory::getLocalClusterInstance()
101 public static function getLocalClusterInstance() {
102 return MediaWikiServices
::getInstance()->getObjectCacheFactory()
103 ->getLocalClusterInstance();
107 * @deprecated since 1.42, Use ObjectCacheFactory::clear() instead.
109 * Clear all the cached instances.
111 public static function clear() {
112 MediaWikiServices
::getInstance()->getObjectCacheFactory()->clear();