I've came across one issue, when using Memory Caching in 5.1.0 version of In-Portal.
- there are 2 developers
- each developer uses it's own copy of in-portal code
- both developers connect to the same database
When all cache was stored in database, then 2nd developer will immediately have changed, that 1st developer have cached. For example, when 1st developer adds new menu item on Front-End, then 2nd developer will see it immediately, since it's cached to "cms_menu" cache.
In memory caching implementation we have protection against case, when 2 websites on In-Portal will use common cache instead of separate. This protection has side effect, that 1st and 2nd developers now will have own
cache versions and 2nd developer will have to rebuild cache to see, what 1st developer have placed into it (since cache is build based on common database in my example).
This all happens because of each memory cache key has prefix based on In-Portal installation folder full path (FULL_PATH constant), which is different for both developers. If we will replace it with relative In-Portal installation folder (BASE_PATH constant), then it will do us no good, since it will be "/" for most of the sites and as a result will mix up caches of 2 separate In-Portal installations on same server.
I really don't know if this is a bug or a feature, since database is shared, but cached data isn't.
I suddenly got idea, how to fix that:
Here is problematic line $site_key = 'site_serial:' . crc32(FULL_PATH); of kCache::_cachePrefix method. We can do 2 things here:
- move it to new class attribute, so we don't have to calculate crc32 for each stored/retrieved key + replace $site_key with that attribute usage;
- use BASE_PATH constant instead of FULL_PATH, when we have *$_CONFIG['Misc']['Mode] = 'development';* (new config variable) set in config.php file.