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:
77
88services :
99 phpfastcache :
10+ factory : ['%php_fast_cache.cache.class%', 'getInstance']
1011 class : " %php_fast_cache.cache.class%"
1112 arguments :
1213 - " %phpfastcache%"
Original file line number Diff line number Diff line change 2626 */
2727class Cache
2828{
29+ /**
30+ * @var self
31+ */
32+ protected static $ selfInstance ;
33+
2934 /**
3035 * @var array
3136 */
32- private $ config = [];
37+ protected $ config = [];
3338
3439 /**
3540 * @var Stopwatch
@@ -41,7 +46,7 @@ class Cache
4146 *
4247 * @var \phpFastCache\Core\Pool\ExtendedCacheItemPoolInterface[]
4348 */
44- private $ cacheInstances = [];
49+ protected $ cacheInstances = [];
4550
4651 /**
4752 * Cache constructor.
@@ -51,12 +56,26 @@ class Cache
5156 *
5257 * @throws \phpFastCache\Exceptions\phpFastCacheDriverException
5358 */
54- public function __construct ($ config , Stopwatch $ stopwatch = null )
59+ protected function __construct ($ config , Stopwatch $ stopwatch = null )
5560 {
5661 $ this ->config = (array ) $ config ;
5762 $ this ->stopwatch = $ stopwatch ;
5863 }
5964
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+
6079 /**
6180 * Set a new cache instance
6281 *
You can’t perform that action at this time.
0 commit comments