Skip to content

Slow CacheManager::getDriverList() #920

@MaximilianKresse

Description

@MaximilianKresse

What type of issue is this?

Other (Please Specify)

Operating system + version

Ubuntu 22.04

PHP version

8.2.24

Connector/Database version (if applicable)

No response

Phpfastcache version

9.2.0 ✅

Describe the issue you're facing

I'm currently trying to improve the speed of our controller and stumbled over something unexpected. We're currently adding a custom driver to PhpFastCache (with CacheManager::addCoreDriverOverride) and this calls internally CacheManager::getDriverList().

The method "CacheManager::getDriverList()" currently needs ~60ms on our development server. Yes this harddrive on this server is pretty slow - but why does this method work like this at all - in a library which you only want to use if you want to improve your speed.

Currently the CacheManager::getDriverList() method walks recursively over all files in the Drivers directory and then loads ALL php files in these completly into the memory and tokenizes them. Just to generate a list of classes which are always the same (at least if you don't change driver directory). This logic is probably a relict of the old way extension where added - but as far as I see this is no longer the case.

Can we please fix this?

Currently I see two ways to simply fix this:

  1. Replace this logic in getDriverList() by a simple hardcoded list of drivers.
  2. Add an option to insert the list from outside - something like CacheManager::setDriverList()

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions