Guest User

Untitled

a guest
Nov 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. Index: Service/Cache.php
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. --- Service/Cache.php (revision e972969478c2ad67d9befe771b5783d57aea7542)
  7. +++ Service/Cache.php (revision )
  8. @@ -26,10 +26,15 @@
  9. */
  10. class Cache
  11. {
  12. + /**
  13. + * @var self
  14. + */
  15. + protected static $selfInstance;
  16. +
  17. /**
  18. * @var array
  19. */
  20. - private $config = [];
  21. + protected $config = [];
  22.  
  23. /**
  24. * @var Stopwatch
  25. @@ -41,7 +46,7 @@
  26. *
  27. * @var \phpFastCache\Core\Pool\ExtendedCacheItemPoolInterface[]
  28. */
  29. - private $cacheInstances = [];
  30. + protected $cacheInstances = [];
  31.  
  32. /**
  33. * Cache constructor.
  34. @@ -51,12 +56,26 @@
  35. *
  36. * @throws \phpFastCache\Exceptions\phpFastCacheDriverException
  37. */
  38. - public function __construct($config, Stopwatch $stopwatch = null)
  39. + protected function __construct($config, Stopwatch $stopwatch = null)
  40. {
  41. $this->config = (array) $config;
  42. $this->stopwatch = $stopwatch;
  43. }
  44.  
  45. + /**
  46. + * Factory instance provider
  47. + *
  48. + * @param array $config
  49. + * @param Stopwatch $stopwatch
  50. + *
  51. + * @throws \phpFastCache\Exceptions\phpFastCacheDriverException
  52. + * @return self
  53. + */
  54. + public static function getInstance($config, Stopwatch $stopwatch = null)
  55. + {
  56. + return self::$selfInstance ?: self::$selfInstance = new self($config, $stopwatch);
  57. + }
  58. +
  59. /**
  60. * Set a new cache instance
  61. *
  62. Index: Resources/config/services.yml
  63. IDEA additional info:
  64. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  65. <+>UTF-8
  66. ===================================================================
  67. --- Resources/config/services.yml (revision e972969478c2ad67d9befe771b5783d57aea7542)
  68. +++ Resources/config/services.yml (revision )
  69. @@ -7,6 +7,7 @@
  70.  
  71. services:
  72. phpfastcache:
  73. + factory: ['%php_fast_cache.cache.class%', 'getInstance']
  74. class: "%php_fast_cache.cache.class%"
  75. arguments:
  76. - "%phpfastcache%"
Add Comment
Please, Sign In to add comment