Welcome Guest, Not a member yet? Register   Sign In
How to retrive cacheKey generated ?
#1

(This post was last modified: 05-30-2024, 02:48 AM by ALTITUDE_DEV.)

Hello here, 


I have tried several caching methods on my CI 4.5 project, and the method `$this->cachePage(2500);` is the most efficient (less than 40ms). My question is as follows:

So, I am performing caching with: `$this->cachePage(TIME);`
How can I get the randomly generated cache key created by the CI caching system?

we need this key: 
[Image: dTbxhHp.png]

The key, something like in MD5, I would need it to be able to create a function to delete the cache of the concerned page.

Thank you for your help.
Reply
#2

See https://github.com/codeigniter4/CodeIgni...hp#L74-L87
Reply
#3

(This post was last modified: 05-30-2024, 04:02 AM by ALTITUDE_DEV.)

Hi thanks for reply
I have make this and is working Wink 

PHP Code:
/**
* getCacheKey
* @var url
* @var get/post
*/
if (! function_exists('getCachedKey')) {
    function getCachedKey($uriSend$method){
        $request  = \Config\Services::request();
        if($method == false){
            $methodReq $request->getMethod();
        }else{
            $methodReq $method;
        }
        if($uriSend == false){
            $uri $request->getUri();
        }else{
            $uri = new \CodeIgniter\HTTP\URI($uriSend);
        }
        $query '';
        return md5($methodReq ':' $uri->setFragment('')->setQuery($query));
    }

Reply
#4

You can use the forum search
https://forum.codeigniter.com/showthread.php?tid=90893
Simple CI 4 project for beginners codeigniter-expenses
Reply
#5

(05-30-2024, 05:10 AM)ozornick Wrote: You can use the forum search
https://forum.codeigniter.com/showthread.php?tid=90893

If I ask the question, it is because the answer has not been found. I had actually found this function before even posting a request on the forum Wink
Reply




Theme © iAndrew 2016 - Forum software by © MyBB