/** * @dataProvider cacheAvailabilityProvider */ public function testCacheAvailability($localCache, $distributedCache, $lockingCache, $expectedLocalCache, $expectedDistributedCache, $expectedLockingCache) { $logger = $this->getMockBuilder('\\OCP\\ILogger')->getMock(); $factory = new \OC\Memcache\Factory('abc', $logger, $localCache, $distributedCache, $lockingCache); $this->assertTrue(is_a($factory->createLocal(), $expectedLocalCache)); $this->assertTrue(is_a($factory->createDistributed(), $expectedDistributedCache)); $this->assertTrue(is_a($factory->createLocking(), $expectedLockingCache)); }
/** * @brief Constructor * @param $configPrefix a string with the prefix for the configkey column (appconfig table) * @param $configID a string with the value for the appid column (appconfig table) or null for on-the-fly connections */ public function __construct(ILDAPWrapper $ldap, $configPrefix = '', $configID = 'user_ldap') { parent::__construct($ldap); $this->configPrefix = $configPrefix; $this->configID = $configID; $this->configuration = new Configuration($configPrefix); $memcache = new \OC\Memcache\Factory(); if ($memcache->isAvailable()) { $this->cache = $memcache->create(); } else { $this->cache = \OC_Cache::getGlobalCache(); } $this->hasPagedResultSupport = $this->ldap->hasPagedResultSupport(); $this->doNotValidate = !in_array($this->configPrefix, Helper::getServerConfigurationPrefixes()); }
/** * @dataProvider cacheAvailabilityProvider */ public function testCacheAvailability($localCache, $distributedCache, $lockingCache, $expectedLocalCache, $expectedDistributedCache, $expectedLockingCache) { $factory = new \OC\Memcache\Factory('abc', $localCache, $distributedCache, $lockingCache); $this->assertTrue(is_a($factory->createLocal(), $expectedLocalCache)); $this->assertTrue(is_a($factory->createDistributed(), $expectedDistributedCache)); $this->assertTrue(is_a($factory->createLocking(), $expectedLockingCache)); }
protected static function registerAutoloaderCache() { // The class loader takes an optional low-latency cache, which MUST be // namespaced. The instanceid is used for namespacing, but might be // unavailable at this point. Futhermore, it might not be possible to // generate an instanceid via \OC_Util::getInstanceId() because the // config file may not be writable. As such, we only register a class // loader cache if instanceid is available without trying to create one. $instanceId = \OC::$server->getSystemConfig()->getValue('instanceid', null); if ($instanceId) { try { $memcacheFactory = new \OC\Memcache\Factory($instanceId); self::$loader->setMemoryCache($memcacheFactory->createLowLatency('Autoloader')); } catch (\Exception $ex) { } } }