当前位置: 首页>>代码示例>>PHP>>正文


PHP ObjectCache类代码示例

本文整理汇总了PHP中ObjectCache的典型用法代码示例。如果您正苦于以下问题:PHP ObjectCache类的具体用法?PHP ObjectCache怎么用?PHP ObjectCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObjectCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getVariables

 private static function getVariables()
 {
     ObjectCache::getInstance();
     $site = Site::getInstance();
     define('GUEST_ROLE_ID', (int) $site->getGuestRoleID()->getValue());
     define('SITE_EMAIL', $site->getEmail());
     define('SITE_TITLE', $site->getTitle());
     date_default_timezone_set($site->getTimeZone());
     if ($site->isInMaintenanceMode()) {
         if (!PermissionEngine::getInstance()->currentUserCanDo('bypasssMaintenanceMode')) {
             return;
         }
     }
     $blockEngine = BlockEngine::getInstance();
     $user = CurrentUser::getUserSession();
     $hookEngine = HookEngine::getInstance();
     $router = Router::getInstance();
     $hookEngine->runAction('addStaticRoutes');
     $moduleInCharge = $router->whichModuleHandlesRequest();
     $response = self::getResponse($moduleInCharge);
     http_response_code($response->getResponseCode());
     $headers = $response->getHeaders();
     foreach ($headers as $header => $value) {
         header($header . ": " . $value, true);
     }
     define('PAGE_TYPE', $response->getPageType());
     $blocks = $blockEngine->getBlocks($site->getTheme(), PAGE_TYPE, $user->getRoleID());
     if ($blocks === null) {
         $blocks = array();
     }
     self::render($site, $response, $blocks);
 }
开发者ID:educask,项目名称:EducaskCore,代码行数:32,代码来源:Bootstrap.php

示例2: getBlackList

 public static function getBlackList()
 {
     $cache = \ObjectCache::getMainWANInstance();
     return $cache->getWithSetCallback(wfMemcKey('flowthread', 'spamblacklist'), 60, function () {
         return self::buildBlacklist();
     });
 }
开发者ID:moegirlwiki,项目名称:MW-FlowThread,代码行数:7,代码来源:SpamFilter.php

示例3: clearOldCache

 private static function clearOldCache()
 {
     if (self::$instance->lastClear > strtotime("-30 minutes")) {
         return;
     }
     self::$instance = new ObjectCache();
 }
开发者ID:educask,项目名称:EducaskCore,代码行数:7,代码来源:ObjectCache.php

示例4: __construct

 public function __construct($parent)
 {
     global $wgMemc;
     $this->parent = $parent;
     $this->srvCache = ObjectCache::newAccelerator(array(), 'hash');
     $this->mainCache = $wgMemc ?: wfGetMainCache();
 }
开发者ID:KaralisWebLabs,项目名称:mediawiki,代码行数:7,代码来源:LoadMonitor.php

示例5: show

 public static function show($objectId, $jsonLast = null)
 {
     $db = Core::getDb();
     $user = Core::getUser();
     $comments = array();
     $qLast = $jsonLast ? "and c.id>" . $db->escape($jsonLast) : "";
     $q = $db->buildQuery("SELECT c.id, c.body, o.ctime, u.id as local_user_id, o.user_id, c.user_connection_id, con.service, con.external_id\n      FROM comments c\n      LEFT JOIN objects o ON o.object_id=c.object_id\n      LEFT JOIN connections con ON c.user_connection_id=con.id\n\t\t\tLEFT JOIN users u ON u.id=o.user_id\n      WHERE c.in_reply_to_id=%d {$qLast}\n      ORDER BY o.ctime ASC", $objectId);
     $rs = $db->query($q);
     if ($rs && $db->numrows($rs)) {
         while ($o = $db->fetchObject($rs)) {
             $commentAuthor = ObjectCache::getByType('\\Kiki\\User', $o->user_id ? $o->user_id : $o->local_user_id);
             if ($commentAuthor) {
                 if ($o->external_id) {
                     // HACK: should not always have to load this, but this is quicker than getStoredConnections for User 0
                     $connection = User\Factory::getInstance($o->service, $o->external_id, 0);
                     // $connection = $commentAuthor->getConnection($o->service. "_". $o->external_id, true);
                     if ($connection) {
                         $serviceName = $connection->serviceName();
                         $name = $connection->name();
                         $pic = $connection->picture();
                     } else {
                         $serviceName = 'None';
                         // SNH
                         $name = $commentAuthor->name();
                         $pic = $commentAuthor->picture();
                     }
                 } else {
                     $serviceName = 'None';
                     // Kiki
                     $name = $commentAuthor->name();
                     $pic = $commentAuthor->picture();
                 }
             } else {
                 $serviceName = 'None';
                 $name = "Anonymous";
                 $pic = null;
             }
             if ($jsonLast !== null) {
                 $comments[] = Comments::showSingle($objectId, $o->id, $name, $pic, $serviceName, $o->body, $o->ctime);
             } else {
                 $comment = array('objectId' => $objectId, 'id' => $o->id, 'name' => $name, 'pic' => $pic, 'type' => $serviceName, 'body' => $o->body, 'ctime' => $o->ctime, 'dateTime' => date("c", strtotime($o->ctime)), 'relTime' => Misc::relativeTime($o->ctime));
                 $comments[] = $comment;
             }
         }
     } else {
         if ($jsonLast === null) {
             $comments[] = Comments::showDummy($objectId);
         }
     }
     if ($jsonLast !== null) {
         return $comments;
     }
     $template = new Template('parts/comments');
     $template->assign('objectId', $objectId);
     $template->assign('comments', $comments);
     return $template->fetch();
 }
开发者ID:robkaper,项目名称:kiki,代码行数:57,代码来源:comments.php

示例6: delete

 public function delete()
 {
     $query = "DELETE from " . self::DB_TABLE;
     $query .= " WHERE user_id = " . $this->userID;
     $query .= " AND project_id = " . $this->projectID;
     $db = Db::instance();
     $db->execute($query);
     ObjectCache::remove(get_class($this), $this->id);
 }
开发者ID:malimu,项目名称:Pipeline,代码行数:9,代码来源:projectUser.class.php

示例7: testMakeKey

 /**
  * @covers BagOStuff::makeGlobalKey
  * @covers BagOStuff::makeKeyInternal
  */
 public function testMakeKey()
 {
     $cache = ObjectCache::newFromId('hash');
     $localKey = $cache->makeKey('first', 'second', 'third');
     $globalKey = $cache->makeGlobalKey('first', 'second', 'third');
     $this->assertStringMatchesFormat('%Sfirst%Ssecond%Sthird%S', $localKey, 'Local key interpolates parameters');
     $this->assertStringMatchesFormat('global%Sfirst%Ssecond%Sthird%S', $globalKey, 'Global key interpolates parameters and contains global prefix');
     $this->assertNotEquals($localKey, $globalKey, 'Local key and global key with same parameters should not be equal');
 }
开发者ID:rrameshs,项目名称:mediawiki,代码行数:13,代码来源:BagOStuffTest.php

示例8: templateData

 public function templateData()
 {
     $uAuthor = ObjectCache::getByType('\\Kiki\\User', $this->userId);
     $data = array('id' => $this->id, 'url' => $this->url(), 'ctime' => strtotime($this->ctime), 'relTime' => Misc::relativeTime($this->ctime), 'title' => $this->title(), 'body' => $this->body, 'author' => $uAuthor->name(), 'publications' => array(), 'likes' => $this->likes(), 'comments' => Comments::count($this->objectId), 'html' => array('comments' => Comments::show($this->objectId)));
     $publications = $this->publications();
     foreach ($publications as $publication) {
         $data['publications'][] = $publication->templateData();
     }
     return $data;
 }
开发者ID:robkaper,项目名称:kiki,代码行数:10,代码来源:socialupdate.php

示例9: __construct

 /**
  * Constructor. Parameters are:
  *
  *   - caches:   This should have a numbered array of cache parameter
  *               structures, in the style required by $wgObjectCaches. See
  *               the documentation of $wgObjectCaches for more detail.
  *
  * @param array $params
  * @throws MWException
  */
 public function __construct($params)
 {
     if (!isset($params['caches'])) {
         throw new MWException(__METHOD__ . ': the caches parameter is required');
     }
     $this->caches = array();
     foreach ($params['caches'] as $cacheInfo) {
         $this->caches[] = ObjectCache::newFromParams($cacheInfo);
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:20,代码来源:MultiWriteBagOStuff.php

示例10: checkPurge

 /**
  * Check whether feed's cache should be cleared; for changes feeds
  * If the feed should be purged; $timekey and $key will be removed from cache
  *
  * @param string $timekey Cache key of the timestamp of the last item
  * @param string $key Cache key of feed's content
  */
 public static function checkPurge($timekey, $key)
 {
     global $wgRequest, $wgUser;
     $purge = $wgRequest->getVal('action') === 'purge';
     if ($purge && $wgUser->isAllowed('purge')) {
         $cache = ObjectCache::getMainWANInstance();
         $cache->delete($timekey, 1);
         $cache->delete($key, 1);
     }
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:17,代码来源:FeedUtils.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     if ($this->getCliArg('use-wanobjectcache')) {
         $name = $this->getCliArg('use-wanobjectcache');
         $this->cache = ObjectCache::getWANInstance($name);
     } else {
         $this->cache = new WANObjectCache(array('cache' => new HashBagOStuff(), 'pool' => 'testcache-hash', 'relayer' => new EventRelayerNull(array())));
     }
 }
开发者ID:D66Ha,项目名称:mediawiki,代码行数:10,代码来源:WANObjectCacheTest.php

示例12: applyDefaultConfig

 /**
  * @param array $lbConf Config for LBFactory::__construct()
  * @param Config $mainConfig Main config object from MediaWikiServices
  * @return array
  */
 public static function applyDefaultConfig(array $lbConf, Config $mainConfig)
 {
     global $wgCommandLineMode;
     $lbConf += ['localDomain' => new DatabaseDomain($mainConfig->get('DBname'), null, $mainConfig->get('DBprefix')), 'profiler' => Profiler::instance(), 'trxProfiler' => Profiler::instance()->getTransactionProfiler(), 'replLogger' => LoggerFactory::getInstance('DBReplication'), 'queryLogger' => LoggerFactory::getInstance('DBQuery'), 'connLogger' => LoggerFactory::getInstance('DBConnection'), 'perfLogger' => LoggerFactory::getInstance('DBPerformance'), 'errorLogger' => [MWExceptionHandler::class, 'logException'], 'cliMode' => $wgCommandLineMode, 'hostname' => wfHostname(), 'readOnlyReason' => wfConfiguredReadOnlyReason()];
     if ($lbConf['class'] === 'LBFactorySimple') {
         if (isset($lbConf['servers'])) {
             // Server array is already explicitly configured; leave alone
         } elseif (is_array($mainConfig->get('DBservers'))) {
             foreach ($mainConfig->get('DBservers') as $i => $server) {
                 if ($server['type'] === 'sqlite') {
                     $server += ['dbDirectory' => $mainConfig->get('SQLiteDataDir')];
                 } elseif ($server['type'] === 'postgres') {
                     $server += ['port' => $mainConfig->get('DBport')];
                 }
                 $lbConf['servers'][$i] = $server + ['schema' => $mainConfig->get('DBmwschema'), 'tablePrefix' => $mainConfig->get('DBprefix'), 'flags' => DBO_DEFAULT, 'sqlMode' => $mainConfig->get('SQLMode'), 'utf8Mode' => $mainConfig->get('DBmysql5')];
             }
         } else {
             $flags = DBO_DEFAULT;
             $flags |= $mainConfig->get('DebugDumpSql') ? DBO_DEBUG : 0;
             $flags |= $mainConfig->get('DBssl') ? DBO_SSL : 0;
             $flags |= $mainConfig->get('DBcompress') ? DBO_COMPRESS : 0;
             $server = ['host' => $mainConfig->get('DBserver'), 'user' => $mainConfig->get('DBuser'), 'password' => $mainConfig->get('DBpassword'), 'dbname' => $mainConfig->get('DBname'), 'schema' => $mainConfig->get('DBmwschema'), 'tablePrefix' => $mainConfig->get('DBprefix'), 'type' => $mainConfig->get('DBtype'), 'load' => 1, 'flags' => $flags, 'sqlMode' => $mainConfig->get('SQLMode'), 'utf8Mode' => $mainConfig->get('DBmysql5')];
             if ($server['type'] === 'sqlite') {
                 $server['dbDirectory'] = $mainConfig->get('SQLiteDataDir');
             } elseif ($server['type'] === 'postgres') {
                 $server['port'] = $mainConfig->get('DBport');
             }
             $lbConf['servers'] = [$server];
         }
         if (!isset($lbConf['externalClusters'])) {
             $lbConf['externalClusters'] = $mainConfig->get('ExternalServers');
         }
     } elseif ($lbConf['class'] === 'LBFactoryMulti') {
         if (isset($lbConf['serverTemplate'])) {
             $lbConf['serverTemplate']['schema'] = $mainConfig->get('DBmwschema');
             $lbConf['serverTemplate']['sqlMode'] = $mainConfig->get('SQLMode');
             $lbConf['serverTemplate']['utf8Mode'] = $mainConfig->get('DBmysql5');
         }
     }
     // Use APC/memcached style caching, but avoids loops with CACHE_DB (T141804)
     $sCache = MediaWikiServices::getInstance()->getLocalServerObjectCache();
     if ($sCache->getQoS($sCache::ATTR_EMULATION) > $sCache::QOS_EMULATION_SQL) {
         $lbConf['srvCache'] = $sCache;
     }
     $cCache = ObjectCache::getLocalClusterInstance();
     if ($cCache->getQoS($cCache::ATTR_EMULATION) > $cCache::QOS_EMULATION_SQL) {
         $lbConf['memCache'] = $cCache;
     }
     $wCache = MediaWikiServices::getInstance()->getMainWANObjectCache();
     if ($wCache->getQoS($wCache::ATTR_EMULATION) > $wCache::QOS_EMULATION_SQL) {
         $lbConf['wanCache'] = $wCache;
     }
     return $lbConf;
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:59,代码来源:MWLBFactory.php

示例13: __construct

 public function __construct()
 {
     // We use a try/catch instead of the $fallback parameter because
     // we don't want to fail here if $wgObjectCaches is not configured
     // properly for APC setup
     try {
         $this->cache = ObjectCache::newAccelerator();
     } catch (MWException $e) {
         $this->cache = new EmptyBagOStuff();
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:11,代码来源:ExtensionRegistry.php

示例14: testSaveData

 /**
  * Tests saving data.
  */
 public function testSaveData()
 {
     $object = $this->saveObject();
     $this->assertSame($object, $this->cache->get(self::CACHE_KEY));
     // Saving using one way
     ObjectCache::set(self::CACHE_KEY, $object);
     $this->assertSame($object, $this->cache->get(self::CACHE_KEY));
     // Saving using the other way
     $this->cache->{self::CACHE_KEY} = $object;
     $this->assertSame($object, $this->cache->get(self::CACHE_KEY));
     $this->cache->clear();
 }
开发者ID:JerryCR,项目名称:php-2,代码行数:15,代码来源:ObjectCacheTest.php

示例15: setUp

 protected function setUp()
 {
     parent::setUp();
     if ($this->getCliArg('use-wanobjectcache')) {
         $name = $this->getCliArg('use-wanobjectcache');
         $this->cache = ObjectCache::getWANInstance($name);
     } else {
         $this->cache = new WANObjectCache(['cache' => new HashBagOStuff(), 'pool' => 'testcache-hash', 'relayer' => new EventRelayerNull([])]);
     }
     $wanCache = TestingAccessWrapper::newFromObject($this->cache);
     $this->internalCache = $wanCache->cache;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:12,代码来源:WANObjectCacheTest.php


注:本文中的ObjectCache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。