This repository was archived by the owner on Jan 8, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ parameters:
7
7
8
8
services :
9
9
phpfastcache :
10
+ factory : ['%php_fast_cache.cache.class%', 'getInstance']
10
11
class : " %php_fast_cache.cache.class%"
11
12
arguments :
12
13
- " %phpfastcache%"
Original file line number Diff line number Diff line change 26
26
*/
27
27
class Cache
28
28
{
29
+ /**
30
+ * @var self
31
+ */
32
+ protected static $ selfInstance ;
33
+
29
34
/**
30
35
* @var array
31
36
*/
32
- private $ config = [];
37
+ protected $ config = [];
33
38
34
39
/**
35
40
* @var Stopwatch
@@ -41,7 +46,7 @@ class Cache
41
46
*
42
47
* @var \phpFastCache\Core\Pool\ExtendedCacheItemPoolInterface[]
43
48
*/
44
- private $ cacheInstances = [];
49
+ protected $ cacheInstances = [];
45
50
46
51
/**
47
52
* Cache constructor.
@@ -51,12 +56,26 @@ class Cache
51
56
*
52
57
* @throws \phpFastCache\Exceptions\phpFastCacheDriverException
53
58
*/
54
- public function __construct ($ config , Stopwatch $ stopwatch = null )
59
+ protected function __construct ($ config , Stopwatch $ stopwatch = null )
55
60
{
56
61
$ this ->config = (array ) $ config ;
57
62
$ this ->stopwatch = $ stopwatch ;
58
63
}
59
64
65
+ /**
66
+ * Factory instance provider
67
+ *
68
+ * @param array $config
69
+ * @param Stopwatch $stopwatch
70
+ *
71
+ * @throws \phpFastCache\Exceptions\phpFastCacheDriverException
72
+ * @return self
73
+ */
74
+ public static function getInstance ($ config , Stopwatch $ stopwatch = null )
75
+ {
76
+ return self ::$ selfInstance ?: self ::$ selfInstance = new self ($ config , $ stopwatch );
77
+ }
78
+
60
79
/**
61
80
* Set a new cache instance
62
81
*
You can’t perform that action at this time.
0 commit comments