本文整理汇总了PHP中XLite\Core\Database::getCacheDriver方法的典型用法代码示例。如果您正苦于以下问题:PHP Database::getCacheDriver方法的具体用法?PHP Database::getCacheDriver怎么用?PHP Database::getCacheDriver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XLite\Core\Database
的用法示例。
在下文中一共展示了Database::getCacheDriver方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpCheckoutViaHTTPS
protected function setUpCheckoutViaHTTPS($value)
{
\XLite\Core\Database::getRepo('\\XLite\\Model\\Config')->createOption(array('category' => 'Security', 'name' => 'customer_security', 'value' => $value ? 'Y' : 'N'));
// Reset cache - DO NOT CHANGE!
\XLite\Core\Database::getCacheDriver()->deleteAll();
\XLite\Core\Config::getInstance()->Security->customer_security;
}
示例2: removeProductFilterCache
/**
* Remove product filter cache
*
* @param ids IDs OPTIONAL
*
* @return void
*/
public function removeProductFilterCache($ids = null)
{
$cacheDriver = \XLite\Core\Database::getCacheDriver();
if ($ids) {
foreach ($ids as $id) {
$cacheDriver->delete('ProductFilter_Category_Attributes_' . $id);
}
} else {
$categories = $this->createPureQueryBuilder('c')->select('c.category_id')->getQuery()->getScalarResult();
foreach ($categories as $v) {
$cacheDriver->delete('ProductFilter_Category_Attributes_' . $v['category_id']);
}
}
}
示例3: __construct
/**
* Constructor
*
* @return void
*/
public function __construct()
{
$this->em = \XLite\Core\Database::getEM();
$this->translation = \XLite\Core\Translation::getInstance();
$entities = \XLite\Core\Database::getCacheDriver()->fetch('quickEntities');
if (!is_array($entities) || !$entities) {
foreach ($this->em->getMetadataFactory()->getAllMetadata() as $md) {
if (!$md->isMappedSuperclass && preg_match('/^XLite\\\\(?:Module\\\\([a-z0-9]+)\\\\)?Model\\\\(.+)$/iSs', $md->name, $m)) {
$key = ($m[1] ? $m[1] . '\\' : '') . $m[2];
$entities[$key] = $md->name;
}
}
\XLite\Core\Database::getCacheDriver()->save('quickEntities', $entities);
}
$this->entities = $entities;
}
示例4: saveToCache
/**
* Save data to cache
*
* @param mixed $data Data
* @param string $name Cache cell name
* @param array $params Cache cell parameters OPTIONAL
*
* @return void
*/
protected function saveToCache($data, $name, array $params = array())
{
$cell = $this->getCacheCells($name);
if ($cell) {
$hash = $this->getCellHash($name, $cell, $params);
if ($data instanceof \ArrayAccess) {
$this->detachList($data);
} elseif ($data instanceof \XLite\Model\AEntity) {
$data->detach();
}
\XLite\Core\Database::getCacheDriver()->save($this->getCellHash($name, $cell, $params), $data, self::CACHE_DEFAULT_TTL);
} else {
// TODO - add throw exception
}
}
示例5: restoreSkins
/**
* Restore substitutonal skins data from cache
*
* @return void
*/
protected function restoreSkins()
{
$driver = \XLite\Core\Database::getCacheDriver();
$data = $driver ? $driver->fetch(get_called_class() . '.SubstitutonalSkins') : null;
if ($data && is_array($data)) {
$this->resourcesCache = $data;
}
}
示例6: saveDataInCache
/**
* Save data into the cache
*
* @param string $key Key of a cache cell
* @param mixed $data Data object for saving in the cache
*
* @return void
*/
protected function saveDataInCache($key, $data)
{
\XLite\Core\Database::getCacheDriver()->save($this->getKeyHash($key), $data);
}
示例7: saveAttributeOptionsInCache
/**
* Save attribute options into the cache
*
* @param mixed $data Data object for saving in the cache
* @param integer $lifeTime Cell TTL OPTIONAL
*
* @return void
*/
protected function saveAttributeOptionsInCache($data, $lifeTime = 0)
{
\XLite\Core\Database::getCacheDriver()->save($this->getKeyHash(), $data, $lifeTime);
}
示例8: runHelpers
/**
* Execute some methods
*
* @param string $type Helper type
*
* @return void
*/
public function runHelpers($type)
{
$path = \Includes\Utils\FileManager::getCanonicalDir($this->getRepositoryPath());
// Helpers must examine itself if the module has been installed previously
if ($path) {
$helpers = 'post_rebuild' === $type ? $this->postRebuildHelpers : $this->getHelpers($type);
$helpers = (array) $helpers;
foreach ($helpers as $file) {
/** @var \Closure $function */
$function = (require_once $path . $file);
$function();
$this->addInfoMessage('Update hook is run: {{type}}:{{file}}', true, array('type' => $this->getActualName(), 'file' => $file));
}
if ($helpers) {
\XLite\Core\Database::getCacheDriver()->deleteAll();
}
}
}
示例9: testSubstituteMultilanguage
public function testSubstituteMultilanguage()
{
$de = \XLite\Core\Database::getRepo('XLite\\Model\\Language')->findOneBy(array('code' => 'de'));
$de->setStatus(2);
$en = \XLite\Core\Database::getRepo('XLite\\Model\\Language')->findOneBy(array('code' => 'en'));
$en->setStatus(0);
\XLite\Core\Database::getEM()->flush();
\XLite\Core\Database::getCacheDriver()->deleteAll();
$this->openAndWait('');
$this->assertElementPresent("//h1[@class='substitutional-test-skin' and text()='WELCOME PAGE DE']", 'test DE substutional template');
$de->setStatus(0);
$en->setStatus(2);
}
示例10: saveDataInCache
/**
* saveDataInCache
*
* @param string $key Key of a cache cell
* @param mixed $data Data object for saving in the cache
*
* @return void
*/
protected function saveDataInCache($key, $data)
{
\XLite\Core\Database::getCacheDriver()->save(md5($key), $data);
}
示例11: function
/**
* LiteCommerce
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to licensing@litecommerce.com so we can send you a copy immediately.
*
* PHP version 5.3.0
*
* @category LiteCommerce
* @author Creative Development LLC <info@cdev.ru>
* @copyright Copyright (c) 2011-2012 Creative Development LLC <info@cdev.ru>. All rights reserved
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* @link http://www.litecommerce.com/
*/
return function () {
// Apply config changes
$repo = \XLite\Core\Database::getRepo('XLite\\Model\\Config');
$option = $repo->findOneBy(array('name' => 'ga_tracking_type'));
if ($option) {
$option->setType('XLite\\Module\\CDev\\GoogleAnalytics\\View\\FormField\\Select\\TrackingType');
}
\XLite\Core\Database::getEM()->flush();
\XLite\Core\Database::getCacheDriver()->deleteAll();
};
示例12: saveRegistry
/**
* Save registry
*
* @param array $registry Registry
*
* @return void
*/
protected function saveRegistry(array $registry)
{
\XLite\Core\Database::getCacheDriver()->save(static::REGISTRY_CELL, serialize($registry));
}
示例13: savePackagesInCache
/**
* Save packages in cache
*
* @param string $key Cache key
* @param array $data Data to save in cache
*
* @return void
*/
protected function savePackagesInCache($key, $data)
{
\XLite\Core\Database::getCacheDriver()->save($key, $data);
}
示例14: runHelpers
/**
* Execute some helper methods
* Return true if at least one method was executed
*
* @param string $type Helper type
*
* @return boolean
*/
public function runHelpers($type)
{
$result = false;
$path = \Includes\Utils\FileManager::getCanonicalDir($this->getRepositoryPath());
// Helpers must examine itself if the module has been installed previously
if ($path) {
$helpers = 'post_rebuild' === $type ? $this->postRebuildHelpers : $this->getHelpers($type);
$helpers = (array) $helpers;
$invokedHooks = \XLite\Upgrade\Cell::getInstance()->getInvokedHooks();
$pendingHooks = \XLite\Upgrade\Cell::getInstance()->getPendingHooks();
foreach ($helpers as $file) {
if (isset($invokedHooks[$file])) {
// Hook has been invoked earlier, skip...
continue;
}
/** @var \Closure $function */
$function = (require_once $path . $file);
// Prepare argument for hook function
$suffix = '';
$arg = null;
if (!empty($pendingHooks[$file]) && 0 < $pendingHooks[$file]) {
$arg = $pendingHooks[$file];
$suffix = sprintf(' (%d)', $arg);
}
\Includes\Utils\Operator::showMessage(\XLite\Core\Translation::getInstance()->translate('...Invoke {{type}} hook for {{entry}}...', array('type' => $file, 'entry' => addslashes($this->getActualName()) . $suffix)));
// Run hook function
$hookResult = $function($arg);
// Hook has been invoked - return true
$result = true;
// Save result of hook function
\XLite\Upgrade\Cell::getInstance()->addPassedHook($file, intval($hookResult));
$this->addInfoMessage('Update hook is run: {{type}}:{{file}}', true, array('type' => $this->getActualName(), 'file' => $file . $suffix));
if (0 < intval($hookResult)) {
\XLite\Upgrade\Cell::getInstance()->setHookRedirect(true);
break;
}
}
if ($helpers) {
\XLite\Core\Database::getCacheDriver()->deleteAll();
}
}
return $result;
}
示例15: __construct
/**
* Constructor
*
* @param string $namespace Namesapce
* @param \XLite\Core\Cache $driver Driver OPTIONAL
*
* @return void
*/
public function __construct($namespace, \XLite\Core\Cache $driver = null)
{
$this->namespace = $namespace;
$this->driver = $driver ?: \XLite\Core\Database::getCacheDriver();
}