1

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?

a-am
  • 2,857
  • 1
  • 19
  • 25

1 Answers1

3

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.

Brad Bell
  • 67,440
  • 6
  • 73
  • 143
  • Would FileCache be a recommended method? And do you normally save data as JSON? – a-am 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