Joomla 3.x find code for SECOND string of hash hex digits while creating cache file Topic is solved

Discussion regarding Joomla! 3.x Performance issues.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
Sarge_2022
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Jul 13, 2022 3:49 pm

Joomla 3.x find code for SECOND string of hash hex digits while creating cache file

Post by Sarge_2022 » Wed Jul 13, 2022 3:56 pm

Hello to Joomla Community !
My environment - CentOS 7, PHP 7.4, Joomla 3.9.28 with enabled native Joomla cache plugin and Global Configuration -> System -> Cache Handler -> File - path /cache
So cache files created under /cache/page/ looks like
d6ce7bd2b5485ba575657fa6cfd878dc-cache-page-2309b00ab41ee13659dcb835b1a1b484.php
as per Joomla documentation "second string of hex digits is a hash of the URL of the site web page, to make the filename unique to that page"
I suppose every cache file has created by native Joomla plugin
/plugins/system/cache/cache.php
But I cannot find a part of code what creates SECOND STRING of HASH in cache file name as above underlined - 2309b00ab41ee13659dcb835b1a1b484
Please, advise - where I could find this part of code ?
(I'd like to write a small improvement to store these unique hash of cache file in MySQL database for my own purposes - but WHAT creates this hash ? ??? )
Last edited by imanickam on Wed Jul 13, 2022 5:06 pm, edited 1 time in total.
Reason: Corrected the word Cache - from Cash

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2910
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Joomla 3.x find code for SECOND string of hash hex digits while creating cache file

Post by SharkyKZ » Wed Jul 13, 2022 4:16 pm

It's created in Joomla\CMS\Cache\CacheStorage::_getCacheId() method.
Last edited by imanickam on Wed Jul 13, 2022 5:07 pm, edited 1 time in total.
Reason: Corrected the word Cache - from Cash

Sarge_2022
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Jul 13, 2022 3:49 pm

Re: Joomla 3.x find code for SECOND string of hash hex digits while creating cache file

Post by Sarge_2022 » Wed Jul 13, 2022 5:33 pm

Thanks a lot ! You already gave me the right direction.
Last edited by Sarge_2022 on Wed Jul 13, 2022 6:15 pm, edited 1 time in total.

Sarge_2022
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Jul 13, 2022 3:49 pm

Re: Joomla 3.x find code for SECOND string of hash hex digits while creating cache file

Post by Sarge_2022 » Wed Jul 13, 2022 6:15 pm

SharkyKZ wrote:
Wed Jul 13, 2022 4:16 pm
It's created in Joomla\CMS\Cache\CacheStorage::_getCacheId() method.
Thanks a lot ! You already gave me the right direction.
If you could just say me is it possible to call the function as a variable like
$cid = JFactory::_getCacheId();
or with other syntax ?
...IDEALLY if I could add such a variable to
/plugins/system/cache/cache.php
where
// Saves current page in cache.
$this->_cache->store($this->app->getBody(), $this->getCacheKey());
$cid = JFactory::_getCacheId();
if it's possible

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2910
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Joomla 3.x find code for SECOND string of hash hex digits while creating cache file

Post by SharkyKZ » Wed Jul 13, 2022 7:20 pm

No, not normally. It's a protected method.


Locked

Return to “Performance - Joomla! 3.x”