Example #1
0
 /**
  * Returns the cache object or creates a new one if it doesn't exist yet.
  *
  * @return \MW_Cache_Interface 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 = \MW_Cache_Factory::createManager('Typo3', $conf, $this->_cache);
     }
     return $this->_object;
 }
Example #2
0
 /**
  * Returns the cache object
  *
  * @return MW_Cache_Interface 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());
         $client = new Predis\Client($conn, $conf);
         $conf = array('siteid' => $context->getLocale()->getSiteId());
         $this->_object = MW_Cache_Factory::createManager('Redis', $conf, $client);
     }
     return $this->_object;
 }
Example #3
0
 /**
  * Returns the cache object
  *
  * @return MW_Cache_Interface 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 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 = MW_Cache_Factory::createManager('Redis', $conf, $client);
     }
     return $this->_object;
 }
Example #4
0
 /**
  * Returns the cache object for the context
  *
  * @param \MShop_Context_Item_Interface $context Context object including config
  * @param string $siteid Unique site ID
  * @return \MW_Cache_Interface Cache object
  */
 protected static function getCache(\MShop_Context_Item_Interface $context)
 {
     $config = $context->getConfig();
     switch (Base::getExtConfig('cacheName', 'Typo3')) {
         case 'None':
             $config->set('client/html/basket/cache/enable', false);
             return \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 \MAdmin_Cache_Proxy_Typo3($context, $manager->getCache('aimeos'));
         default:
             return new \MAdmin_Cache_Proxy_Default($context);
     }
 }
Example #5
0
 /**
  * Returns the cache object
  *
  * @return MW_Cache_Interface Cache object
  */
 public function getCache()
 {
     return MW_Cache_Factory::createManager('None', array(), null);
 }
Example #6
0
 /**
  * Returns the cache object for the context
  *
  * @param \MShop_Context_Item_Interface $context Context object
  * @return \MW_Cache_Interface Cache object
  */
 protected function getCache(\MShop_Context_Item_Interface $context)
 {
     switch ($context->getConfig()->get('flow/cache/name', 'Flow')) {
         case 'None':
             $config->set('client/html/basket/cache/enable', false);
             return \MW_Cache_Factory::createManager('None', array(), null);
         case 'Flow':
             return new \MAdmin_Cache_Proxy_Flow($context, $this->cache);
         default:
             return new \MAdmin_Cache_Proxy_Default($context);
     }
 }
Example #7
0
 /**
  * Returns the cache object
  *
  * @return MW_Cache_Interface Cache object
  */
 public function getCache()
 {
     if (!isset($this->_object)) {
         /** madmin/cache/manager/default/deletebytag
          * 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/default/delete
          * @see madmin/cache/manager/default/get
          * @see madmin/cache/manager/default/getbytag
          * @see madmin/cache/manager/default/set
          * @see madmin/cache/manager/default/settag
          * @see madmin/cache/manager/default/search
          * @see madmin/cache/manager/default/count
          */
         /** madmin/cache/manager/default/getbytag
          * 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/default/delete
          * @see madmin/cache/manager/default/deletebytag
          * @see madmin/cache/manager/default/get
          * @see madmin/cache/manager/default/set
          * @see madmin/cache/manager/default/settag
          * @see madmin/cache/manager/default/search
          * @see madmin/cache/manager/default/count
          */
         /** madmin/cache/manager/default/get
          * 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/default/getbytag
          * @see madmin/cache/manager/default/delete
          * @see madmin/cache/manager/default/deletebytag
          * @see madmin/cache/manager/default/set
          * @see madmin/cache/manager/default/settag
          * @see madmin/cache/manager/default/search
          * @see madmin/cache/manager/default/count
          */
         $context = $this->_getContext();
         $config = $context->getConfig();
         $name = $config->get('resource/db/adapter');
         $name = $config->get('resource/db-cache/adapter', $name);
         /** classes/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 MW_Cache_* class.
          *
          * @param string Name of the cache class
          * @since 2014.09
          * @category Developer
          */
         $name = $config->get('classes/cache/name', $name);
         $config = array('search' => $this->_searchConfig, 'dbname' => $this->_getResourceName(), 'siteid' => $context->getLocale()->getSiteId(), 'sql' => array('delete' => $config->get('madmin/cache/manager/default/delete'), 'deletebytag' => $config->get('madmin/cache/manager/default/deletebytag'), 'getbytag' => $config->get('madmin/cache/manager/default/getbytag'), 'get' => $config->get('madmin/cache/manager/default/get'), 'set' => $config->get('madmin/cache/manager/default/set'), 'settag' => $config->get('madmin/cache/manager/default/settag')));
         $dbm = $context->getDatabaseManager();
         try {
             $this->_object = MW_Cache_Factory::createManager($name, $config, $dbm);
         } catch (Exception $e) {
             $this->_object = MW_Cache_Factory::createManager('DB', $config, $dbm);
         }
     }
     return $this->_object;
 }
Example #8
0
 public function testFactoryInvalidClass()
 {
     $this->setExpectedException('MW_Cache_Exception');
     MW_Cache_Factory::createManager('Invalid', array(), null);
 }