[V5˖] Why calling getInstance() each time is a bad practice ? - PHPSocialNetwork/phpfastcache GitHub Wiki
:interrobang: Why
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.
:red_circle: The wrong way
$cacheItem = CacheManager::getInstance('driverName')->getItem('myKey')->get();
$cacheItem2 = CacheManager::getInstance('driverName')->getItem('myKey2')->get();
$cacheItem3 = CacheManager::getInstance('driverName')->getItem('myKey3')->get();
:white_check_mark: The right way
$driverInstance = CacheManager::getInstance('driverName');
$cacheItem = $driverInstance->getItem('myKey')->get();
$cacheItem2 = $driverInstance->getItem('myKey2')->get();
$cacheItem3 = $driverInstance->getItem('myKey3')->get();