logo

Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

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.