/** * Clears the content cache * * @param string $sites List of sites separated by a space character the jobs should be executed for, e.g. "default unittest" * @return void */ public function cacheCommand($sites = '') { $context = $this->objectManager->get('\\Aimeos\\Shop\\Base\\Context')->get(null, 'command'); $context->setEditor('aimeos:cache'); $config = $context->getConfig(); $name = $config->get('flow/cache/name', 'Flow'); $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); foreach ($this->getSiteItems($context, $sites) as $siteItem) { $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false); $lcontext = clone $context; $lcontext->setLocale($localeItem); switch ($name) { case 'None': $config->set('client/html/basket/cache/enable', false); $cache = \Aimeos\MW\Cache\Factory::createManager('None', array(), null); break; case 'Flow': $cache = new \Aimeos\MAdmin\Cache\Proxy\Flow($lcontext, $this->cache); break; default: $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($lcontext); break; } $this->outputFormatted('Clearing the Aimeos cache for site <b>%s</b>', array($siteItem->getCode())); $cache->flush(); } }
/** * Returns the cache object or creates a new one if it doesn't exist yet. * * @return \Aimeos\MW\Cache\Iface Cache object */ protected function getObject() { if (!isset($this->object)) { $siteid = $this->context->getLocale()->getSiteId(); $conf = array('siteid' => $this->context->getConfig()->get('madmin/cache/prefix') . $siteid); $this->object = \Aimeos\MW\Cache\Factory::createManager('Flow', $conf, $this->cache); } return $this->object; }
/** * Returns the cache object * * @return \Aimeos\MW\Cache\Iface Cache object */ public function getCache() { if (!isset($this->object)) { $context = $this->getContext(); $config = $context->getConfig(); $conn = $config->get('resource/cache/redis/connection'); $conf = $config->get('resource/cache/redis', array()); if (!class_exists('\\Predis\\Client')) { throw new \Aimeos\MAdmin\Cache\Exception(sprintf('Please install "%1$s" via composer first', 'predis/predis')); } $client = new \Predis\Client($conn, $conf); $conf = array('siteid' => $context->getLocale()->getSiteId()); $this->object = \Aimeos\MW\Cache\Factory::createManager('Redis', $conf, $client); } return $this->object; }
/** * Returns the cache object for the context * * @param \Aimeos\MShop\Context\Item\Iface $context Context object including config * @param string $siteid Unique site ID * @return \Aimeos\MW\Cache\Iface Cache object */ protected static function getCache(\Aimeos\MShop\Context\Item\Iface $context) { $config = $context->getConfig(); switch (Base::getExtConfig('cacheName', 'Typo3')) { case 'None': $config->set('client/html/basket/cache/enable', false); return \Aimeos\MW\Cache\Factory::createManager('None', array(), null); case 'Typo3': if (class_exists('\\TYPO3\\CMS\\Core\\Cache\\Cache')) { \TYPO3\CMS\Core\Cache\Cache::initializeCachingFramework(); } $manager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager'); return new \Aimeos\MAdmin\Cache\Proxy\Typo3($context, $manager->getCache('aimeos')); default: return new \Aimeos\MAdmin\Cache\Proxy\Standard($context); } }
/** * Adds the cache object to the context * * @param \Aimeos\MShop\Context\Item\Iface $context Context object including config * @return \Aimeos\MShop\Context\Item\Iface Modified context object */ protected static function addCache(\Aimeos\MShop\Context\Item\Iface $context) { if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_cache']) && is_callable($fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_cache'])) { return $fcn($context); } switch (\Aimeos\Aimeos\Base::getExtConfig('cacheName', 'Typo3')) { case 'None': $context->getConfig()->set('client/html/basket/cache/enable', false); $cache = \Aimeos\MW\Cache\Factory::createManager('None', array(), null); break; case 'Typo3': $manager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager'); $cache = new \Aimeos\MAdmin\Cache\Proxy\Typo3($context, $manager->getCache('aimeos')); break; default: $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context); } return $context->setCache($cache); }
/** * Returns the cache object * * @return \Aimeos\MW\Cache\Iface Cache object */ public function getCache() { return \Aimeos\MW\Cache\Factory::createManager('None', array(), null); }
public function testFactoryInvalidClass() { $this->setExpectedException('\\Aimeos\\MW\\Cache\\Exception'); \Aimeos\MW\Cache\Factory::createManager('InvalidCache', array(), null); }
/** * Returns the cache object * * @return \Aimeos\MW\Cache\Iface Cache object */ public function getCache() { if (!isset($this->object)) { /** madmin/cache/manager/standard/deletebytag/mysql * Deletes the items from the database matched by the given tags * * @see madmin/cache/manager/standard/deletebytag/ansi */ /** madmin/cache/manager/standard/deletebytag/ansi * Deletes the items from the database matched by the given tags * * Removes the records specified by the given tags from the cache database. * The records must be from the site that is configured via the * context item. * * The ":cond" placeholder is replaced by the name of the tag column and * the given tag or list of tags. * * The SQL statement should conform to the ANSI standard to be * compatible with most relational database systems. This also * includes using double quotes for table and column names. * * @param string SQL statement for deleting items by tags * @since 2014.03 * @category Developer * @see madmin/cache/manager/standard/delete/ansi * @see madmin/cache/manager/standard/get/ansi * @see madmin/cache/manager/standard/getbytag/ansi * @see madmin/cache/manager/standard/set/ansi * @see madmin/cache/manager/standard/settag/ansi * @see madmin/cache/manager/standard/search/ansi * @see madmin/cache/manager/standard/count/ansi */ /** madmin/cache/manager/standard/getbytag/mysql * Retrieves the records from the database matched by the given tags * * @see madmin/cache/manager/standard/getbytag/ansi */ /** madmin/cache/manager/standard/getbytag/ansi * Retrieves the records from the database matched by the given tags * * Fetches the records matched by the given tags from the cache * database. The records must be from the sites that is * configured in the context item. * * The SQL statement should conform to the ANSI standard to be * compatible with most relational database systems. This also * includes using double quotes for table and column names. * * @param string SQL statement for retrieving items by tag * @since 2014.03 * @category Developer * @see madmin/cache/manager/standard/delete/ansi * @see madmin/cache/manager/standard/deletebytag/ansi * @see madmin/cache/manager/standard/get/ansi * @see madmin/cache/manager/standard/set/ansi * @see madmin/cache/manager/standard/settag/ansi * @see madmin/cache/manager/standard/search/ansi * @see madmin/cache/manager/standard/count/ansi */ /** madmin/cache/manager/standard/get/mysql * Retrieves the records matched by the given criteria in the database * * @see madmin/cache/manager/standard/get/ansi */ /** madmin/cache/manager/standard/get/ansi * Retrieves the records matched by the given criteria in the database * * Fetches the records matched by the given criteria from the cache * database. The records must be from the sites that is * configured in the context item. * * To limit the records matched, conditions can be added to the given * criteria object. It can contain comparisons like column names that * must match specific values which can be combined by AND, OR or NOT * operators. The resulting string of SQL conditions replaces the * ":cond" placeholder before the statement is sent to the database * server. * * The SQL statement should conform to the ANSI standard to be * compatible with most relational database systems. This also * includes using double quotes for table and column names. * * @param string SQL statement for searching items * @since 2014.03 * @category Developer * @see madmin/cache/manager/standard/getbytag/ansi * @see madmin/cache/manager/standard/delete/ansi * @see madmin/cache/manager/standard/deletebytag/ansi * @see madmin/cache/manager/standard/set/ansi * @see madmin/cache/manager/standard/settag/ansi * @see madmin/cache/manager/standard/search/ansi * @see madmin/cache/manager/standard/count/ansi */ $context = $this->getContext(); $config = $context->getConfig(); $name = $config->get('resource/db/adapter'); $name = $config->get('resource/db-cache/adapter', $name); /** madmin/cache/name * Specifies the name of the cache class implementation * * There are several implementations available for integrating caches * or providing optimized implementations for certain environments. * This configuration option allows to change the cache implementation * by setting the name of the \Aimeos\MW\Cache\* class. * * @param string Name of the cache class * @since 2014.09 * @category Developer */ $name = $config->get('madmin/cache/name', $name); $config = array('search' => $this->searchConfig, 'dbname' => $this->getResourceName(), 'siteid' => $context->getLocale()->getSiteId(), 'sql' => array('delete' => $this->getSqlConfig('madmin/cache/manager/standard/delete'), 'deletebytag' => $this->getSqlConfig('madmin/cache/manager/standard/deletebytag'), 'getbytag' => $this->getSqlConfig('madmin/cache/manager/standard/getbytag'), 'get' => $this->getSqlConfig('madmin/cache/manager/standard/get'), 'set' => $this->getSqlConfig('madmin/cache/manager/standard/set'), 'settag' => $this->getSqlConfig('madmin/cache/manager/standard/settag'))); $dbm = $context->getDatabaseManager(); try { $this->object = \Aimeos\MW\Cache\Factory::createManager($name, $config, $dbm); } catch (\Exception $e) { $this->object = \Aimeos\MW\Cache\Factory::createManager('DB', $config, $dbm); } } return $this->object; }
/** * Adds the cache object to the context * * @param \Aimeos\MShop\Context\Item\Iface $context Context object including config * @return \Aimeos\MShop\Context\Item\Iface Modified context object */ protected function addCache(\Aimeos\MShop\Context\Item\Iface $context) { $config = $context->getConfig(); switch ($config->get('flow/cache/name', 'Flow')) { case 'None': $config->set('client/html/basket/cache/enable', false); return $context->setCache(\Aimeos\MW\Cache\Factory::createManager('None', array(), null)); case 'Flow': return $context->setCache(new \Aimeos\MAdmin\Cache\Proxy\Flow($context, $this->cache)); default: return $context->setCache(new \Aimeos\MAdmin\Cache\Proxy\Standard($context)); } }