With my plugin I am generating and saving a lot of data to a secondary table. Data that can be generated on the fly that is associated with entries. I have noticed a performance hit and was given a suggestion of caching some of that data instead of writing to a database.

Does craft have a built in caching system I can use for accomplishing something like this?


craft()->cache can point to any one of several different caching drivers as defined by the cacheMethod config setting.

The available methods are all pretty much stock Yii provided caching drivers, with the exception of FileCache, which we've extended a bit.

Note that FileCache is used by default and its values are saved under the craft/storage/runtime/cache folder.

  • Would FileCache be a recommended method? And do you normally save data as JSON?
    – aran
    Oct 27 '14 at 22:33
  • It's the simplest and most general purpose, but it really depends on the context. You can save whatever you want in there. Yii/Craft does it's own serialization to the contents before writing it to the file, anyway.
    – Brad Bell
    Oct 27 '14 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.