mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 22:43:19 +00:00
rename cache service
This commit is contained in:
71
lib/Alchemy/Phrasea/Core/Service/Cache/ApcCache.php
Normal file
71
lib/Alchemy/Phrasea/Core/Service/Cache/ApcCache.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service\Cache;
|
||||
|
||||
use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
use Doctrine\Common\Cache as CacheService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class ApcCache extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'cache';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Cache\ApcCache
|
||||
*/
|
||||
public function getService()
|
||||
{
|
||||
if (!extension_loaded('apc'))
|
||||
{
|
||||
throw new \Exception('The APC cache requires the APC extension.');
|
||||
}
|
||||
|
||||
$registry = $this->getRegistry();
|
||||
|
||||
$service = new CacheService\ApcCache();
|
||||
$service->setNamespace($registry->get("GV_sit", ""));
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'apc';
|
||||
}
|
||||
|
||||
private function getRegistry()
|
||||
{
|
||||
$registry = $this->getDependency("registry");
|
||||
|
||||
if (!$registry instanceof \registryInterface)
|
||||
{
|
||||
throw new \Exception(sprintf('Registry dependency does not implement registryInterface for %s service', $this->name));
|
||||
}
|
||||
|
||||
return $registry;
|
||||
}
|
||||
|
||||
}
|
||||
|
67
lib/Alchemy/Phrasea/Core/Service/Cache/ArrayCache.php
Normal file
67
lib/Alchemy/Phrasea/Core/Service/Cache/ArrayCache.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service\Cache;
|
||||
|
||||
use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
use Doctrine\Common\Cache as CacheService;
|
||||
|
||||
/**
|
||||
* Array cache
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class ArrayCache extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'cache';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Cache\ApcCache
|
||||
*/
|
||||
public function getService()
|
||||
{
|
||||
$registry = $this->getRegistry();
|
||||
|
||||
$service = new CacheService\ArrayCache();
|
||||
$service->setNamespace($registry->get("GV_sit", ""));
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'array';
|
||||
}
|
||||
|
||||
private function getRegistry()
|
||||
{
|
||||
$registry = $this->getDependency("registry");
|
||||
|
||||
if (!$registry instanceof \registryInterface)
|
||||
{
|
||||
throw new \Exception(sprintf('Registry dependency does not implement registryInterface for %s service', $this->name));
|
||||
}
|
||||
|
||||
return $registry;
|
||||
}
|
||||
|
||||
}
|
||||
|
92
lib/Alchemy/Phrasea/Core/Service/Cache/MemcacheCache.php
Normal file
92
lib/Alchemy/Phrasea/Core/Service/Cache/MemcacheCache.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service\Cache;
|
||||
|
||||
use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
use Doctrine\Common\Cache as CacheService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class Memcache extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
const DEFAULT_HOST = "localhost";
|
||||
const DEFAULT_PORT = "11211";
|
||||
|
||||
protected $host;
|
||||
protected $port;
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'cache';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Cache\ApcCache
|
||||
*/
|
||||
public function getService()
|
||||
{
|
||||
if (!extension_loaded('memcache'))
|
||||
{
|
||||
throw new \Exception('The Memcache cache requires the Memcache extension.');
|
||||
}
|
||||
|
||||
$this->host = isset($this->options["host"]) ? $this->options["host"] : self::DEFAULT_HOST;
|
||||
|
||||
$this->port = isset($this->options["port"]) ? $this->options["port"] : self::DEFAULT_PORT;
|
||||
|
||||
$memchache = new \Memcache();
|
||||
$memchache->connect($this->host, $this->port);
|
||||
|
||||
$registry = $this->getRegistry();
|
||||
|
||||
$service = new CacheService\MemcacheCache($memchache);
|
||||
$service->setNamespace($registry->get("GV_sit", ""));
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'memcache';
|
||||
}
|
||||
|
||||
public function getHost()
|
||||
{
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
public function getPort()
|
||||
{
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
private function getRegistry()
|
||||
{
|
||||
$registry = $this->getDependency("registry");
|
||||
|
||||
if (!$registry instanceof \registryInterface)
|
||||
{
|
||||
throw new \Exception(sprintf('Registry dependency does not implement registryInterface for %s service', $this->name));
|
||||
}
|
||||
|
||||
return $registry;
|
||||
}
|
||||
}
|
||||
|
70
lib/Alchemy/Phrasea/Core/Service/Cache/XcacheCache.php
Normal file
70
lib/Alchemy/Phrasea/Core/Service/Cache/XcacheCache.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Core\Service\Cache;
|
||||
|
||||
use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
use Doctrine\Common\Cache as CacheService;
|
||||
|
||||
/**
|
||||
* it's just like array cache
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class XcacheCache extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'cache';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Cache\ApcCache
|
||||
*/
|
||||
public function getService()
|
||||
{
|
||||
if (!extension_loaded('xcache'))
|
||||
{
|
||||
throw new \Exception('The XCache cache requires the XCache extension.');
|
||||
}
|
||||
|
||||
$registry = $this->getRegistry();
|
||||
|
||||
$service = new CacheService\XcacheCache();
|
||||
$service->setNamespace($registry->get("GV_sit", ""));
|
||||
|
||||
return $service;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'xcache';
|
||||
}
|
||||
|
||||
private function getRegistry()
|
||||
{
|
||||
$registry = $this->getDependency("registry");
|
||||
|
||||
if (!$registry instanceof \registryInterface)
|
||||
{
|
||||
throw new \Exception(sprintf('Registry dependency does not implement registryInterface for %s service', $this->name));
|
||||
}
|
||||
|
||||
return $registry;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user