| Use events to clear some selective parts of the cache [message #78011] |
Fri, 08 May 2009 18:03 |
 |
El Riiico Messages: 40 Registered: February 2007 Location: Paris |
Member |
|
|
Hello,
I might not be alone to find that's it's an headache to clear some selective cache in symfony when :
- If you have a backend. And hum, it's an exception when you don't need one on your project, no ?
- If your database can be modified by several ways. For instance, a blog post that can be published by a web form, a mail send or your batch that import an external feed.
When do you need to clear some part of your cache ?
Answer: when the related record in the project model has been modified.
Ok, how could we improve the selective clear cache in an intuitive way ?
By using the cache.yml of my symfony dreams :
myBlogProject/apps/frontend/modules/post/config/cache.yml
show:
with_layout: false
lifetime: 86400
clear-on:
- post.modification
- post.deletion
Here is the idea:
We just have to configure our BlogPost model so it triggers the "post.modification" and "post.deletion" events and that's all.
Thanks to the cache.yml configuration, symfony clears the corresponding cache parts automatically.
Do you like the concept ? Do you think that something is missing ?
http://symfony-check.org
|
|
|