7
* This source file is subject to the new BSD license that is bundled
8
* with this package in the file LICENSE.txt.
9
* It is also available through the world-wide-web at this URL:
10
* http://framework.zend.com/license/new-bsd
11
* If you did not receive a copy of the license and are unable to
12
* obtain it through the world-wide-web, please send an email
13
* to license@zend.com so we can send you a copy immediately.
15
* @package Zend_Memory
16
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
17
* @license http://framework.zend.com/license/new-bsd New BSD License
20
/** Zend_Memory_Exception */
21
require_once 'Zend/Memory/Manager.php';
23
/** Zend_Memory_Exception */
24
require_once 'Zend/Memory/Exception.php';
26
/** Zend_Memory_Value */
27
require_once 'Zend/Memory/Value.php';
29
/** Zend_Memory_Container */
30
require_once 'Zend/Memory/Container.php';
32
/** Zend_Memory_Exception */
33
require_once 'Zend/Cache.php';
38
* @package Zend_Memory
39
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
40
* @license http://framework.zend.com/license/new-bsd New BSD License
47
* @param string $backend backend name
48
* @param array $backendOptions associative array of options for the corresponding backend constructor
49
* @return Zend_Memory_Manager
50
* @throws Zend_Memory_Exception
52
public static function factory($backend, $backendOptions = array())
54
if (strcasecmp($backend, 'none') == 0) {
55
return new Zend_Memory_Manager();
58
// because lowercase will fail
59
$backend = @ucfirst(strtolower($backend));
61
if (!in_array($backend, Zend_Cache::$availableBackends)) {
62
throw new Zend_Memory_Exception("Incorrect backend ($backend)");
65
$backendClass = 'Zend_Cache_Backend_' . $backend;
67
// For perfs reasons, we do not use the Zend_Loader::loadClass() method
68
// (security controls are explicit)
69
require_once str_replace('_', DIRECTORY_SEPARATOR, $backendClass) . '.php';
71
$backendObject = new $backendClass($backendOptions);
73
return new Zend_Memory_Manager($backendObject);