forked from phalcon/cphalcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdapterFactory.zep
82 lines (72 loc) · 2.04 KB
/
AdapterFactory.zep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
* This file is part of the Phalcon Framework.
*
* (c) Phalcon Team <[email protected]>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/
namespace Phalcon\Storage;
use Phalcon\Factory\AbstractFactory;
use Phalcon\Storage\Adapter\AdapterInterface;
class AdapterFactory extends AbstractFactory
{
/**
* @var SerializerFactory
*/
private serializerFactory;
/**
* AdapterFactory constructor.
*/
public function __construct(<SerializerFactory> factory, array! services = [])
{
let this->serializerFactory = factory;
this->init(services);
}
/**
* Create a new instance of the adapter
*
* @param array options = [
* 'servers' => [
* [
* 'host' => '127.0.0.1',
* 'port' => 11211,
* 'weight' => 1
* ]
* ],
* 'defaultSerializer' => 'Php',
* 'lifetime' => 3600,
* 'serializer' => null,
* 'prefix' => '',
* 'host' => '127.0.0.1',
* 'port' => 6379,
* 'index' => 0,
* 'persistent' => false,
* 'auth' => '',
* 'socket' => '',
* 'storageDir' => '',
* ]
*/
public function newInstance(string! name, array! options = []) -> <AdapterInterface>
{
var definition;
let definition = this->getService(name);
return create_instance_params(
definition,
[
this->serializerFactory,
options
]
);
}
protected function getAdapters() -> array
{
return [
"apcu" : "Phalcon\\Storage\\Adapter\\Apcu",
"libmemcached" : "Phalcon\\Storage\\Adapter\\Libmemcached",
"memory" : "Phalcon\\Storage\\Adapter\\Memory",
"redis" : "Phalcon\\Storage\\Adapter\\Redis",
"stream" : "Phalcon\\Storage\\Adapter\\Stream"
];
}
}