Creating a Cached Object

Creating a Cached Object

by Andrew Normore -
Number of replies: 4

Hey, I'm extending $COURSE to have $COURSE->extradata

 

extradata has a LOT of information pulled from the database. How can I cache this information, as it will rarely change?

Average of ratings: -
In reply to Andrew Normore

Re: Creating a Cached Object

by Andrew Normore -

Anyone? sad

In reply to Andrew Normore

Re: Creating a Cached Object

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Don't you think that it would be worth waiting more than an hour, especially at a time of day when many of the users of this forum have gone home for the evening (or are asleep)?

As for caching data - that is up to you and it depends on how long you want to keep it for. It could go in a static variable, in the $SESSION variable, in a file, in a field / table in the database (possibly serialised & base64 encoded). The solution you come up with will depend on exactly what you are doing and how you are doing it.

In reply to Andrew Normore

Re: Creating a Cached Object

by Rex Lorenzo -

I would suggest watching this ticket: http://tracker.moodle.org/browse/MDL-25290

It should allow plugins to store some data into whatever caching solution a system admin of Moodle chooses.