I found I needed to alter the ADOdb cache name generation function, _gencachename, so I've modified the ADOdb caching system to make a new gencachename function part of the (user overrideable) cache class. This means that end users can create or extend a cache class, and set a cache name generation function more appropriate to the caching mechanism, without having to modify ADOdb.
I've also fixed a bug with the _CreateCache function in the ADOConnection class, where it would ignore whatever class the user had specified in $ADODB_CACHE_CLASS if the memCache flag was set. (This was necessary for my particular use case of extending the ADODB_Cache_MemCache class.)
I've also changed a few (now potentially confusing) variable names (e.g. '$filename', '$md5file', '$f') to be '$cachename' in the ADOConnection class.
Backwards compatibility for the common case (i.e. using the built-in file or memcache cache classes) is preserved by this patch, although anyone who has created their own cache class from scratch will need to define a gencachename function for their code to continue working with this patch. Anyone with a cache class extending the built-in cache classes will find it works without need for alteration, though, as the patch defines appropriate gencachename functions for these built-in classes.
(The ADODB_Cache_MemCache class may even be a little faster now, as the gencachename function for it has been stripped of unnecessary createdir-related code.)
Please find attached my patch for v5.18. I hope you find this useful.