Creating a Cached Object

Creating a Cached Object

- Andrew Normore の投稿
返信数: 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?

Andrew Normore への返信

Re: Creating a Cached Object

- Andrew Normore の投稿
Andrew Normore への返信

Re: Creating a Cached Object

- Davo Smith の投稿
画像 Core developers 画像 Particularly helpful Moodlers 画像 Peer reviewers 画像 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.

Andrew Normore への返信

Re: Creating a Cached Object

- 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.