9

We're in the process of building a restfull backend in craft. We had sluggish response times due to the amount of queries done by craft on a an entry listing. Each entry had about 3 levels of nesting and a list of 9 entries tool 10-13 seconds to render.

I've worked around this by outputting the json using twig and its cache. Now I've noticed that craft uses mysql to cache its data. Due to the amount of queries to this backend we will probably run out of its auto incremental key space. This platform has over 2 million unique visitors a day. (I've seen it before and it will happen)

Now my question is can I override the twig cache subsystem? For example use Redis so I can proactively notify middleware and/or frontend that caches have been cleared, so these tiers can regenerate the cache while still serving stale cache? And/or is there an event available inside the cache system so I can trigger on that?

Thanks in advance

5

"Due to the amount of queries to this backend we will probably run out of its auto incremental key space."

That would seem to suggest that maybe your template caching strategy should be re-visited?

Are there really going to be 215 million (from a signed int) unique pieces of cached content that need to be saved?

Now my question is can I override the twig cache subsystem?

Right now, there aren't any hooks or events into the template caching layer, but a few people have asked for it to hook up to external services like memcached, redis, varnish, fastly, etc. So it's on our list to add some events for plugins to get notified when things like cache expiration occurs for a piece of content.

  • Since I had to output my json (rest) using twig to avoid the ssluggish responses, all combinations of params and different apis will be cached in a mysql record. So the maxint scared me a bit. If it was a bigint I would worry that much :) It would be very nice to have such a hook and/or event in that layer. Originally I didnt want to cache at all on that level and let the middleware layer (NodeJS) take care of the caching, but I need some sort of event from the CMS in order to clear and regenerate the cache. – pythic Sep 10 '14 at 17:38
  • BRad, I've read somewhere on a thread here that this feature should be released in 2.2. However I dont think it made it right? Can you tell me when we can expect such a feature. For me its becoming very important issue. Thanks in advance – pythic Sep 11 '14 at 7:26
  • Yeah... didn't make it into 2.2. It's on the 2.3 list, but no ETA on that, sorry. – Brad Bell Sep 11 '14 at 15:37
  • 1
    Hi Brad, any update on this as of 2016? – Simon East Nov 12 '16 at 1:50

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.