-
-
Notifications
You must be signed in to change notification settings - Fork 453
[V5˖] Why calling getInstance() each time is a bad practice ?
Georges.L edited this page Feb 20, 2020
·
3 revisions
CacheManager::getInstance() will return a driver instance and if not exists will create it.
This has a significant impact on performances due to cr32/serialization for seeking existing driver instances.
$cacheItem = CacheManager::getInstance('driverName')->getItem('myKey')->get();
$cacheItem2 = CacheManager::getInstance('driverName')->getItem('myKey2')->get();
$cacheItem3 = CacheManager::getInstance('driverName')->getItem('myKey3')->get();
$driverInstance = CacheManager::getInstance('driverName');
$cacheItem = $driverInstance->getItem('myKey')->get();
$cacheItem2 = $driverInstance->getItem('myKey2')->get();
$cacheItem3 = $driverInstance->getItem('myKey3')->get();
❓ Finally, if you need help, always check out the inevitable README.md