logo

Palette - Make it Colorful🎨

Palette - Visual Page Builder, no design degree required.

Live Demo Download Palette

Scroll

How to work with the cache

22/02/2025, by Anonymous (not verified)
Forums

Hello, I'm creating a module and I've encountered some issues with caching (this is my first time dealing with it). I have $xml which I parsed and stored everything necessary in the variable $res. (Or would it be simpler to just put everything in a block and cache that block?)

Right now, I need to store it in the cache (updating it every 6 hours) and retrieve it upon request.

I know I need to look into 

cache_get
cache_set
hook_cron

But I'm not quite getting how to store it.

As I understand, this code stores data in the cache, but where do all these variables go... where do I insert my variable?

cache_set($cid, $data, $bin = 'cache', $expire ='CACHE_PERMANENT')

To retrieve from the cache 

cache_get ($cid, $bin = "cache")

and for updating, I can't figure out how to use hook_cron.

Please advise me regarding my problem. Thank you in advance.