2

I need to add a simple call to (new sfAPCCache())->clean(), or to apc_clear_cache() when the command ./symfony cc is performed.

Anyone knows how to achieve this? In which point should I edit my symfony application, or how should i register this additional behavior?

2 Answers 2

4

Actually, I discovered that I can listen to an event to add new behavior to ./symfony cc:

$this->dispatcher->connect('task.cache.clear', array('ClearAPCCache','clearCache')) 

Remains the problem that is not possibile to clear the APC cache from a command-line task because APC cache is related to the web server process, while the symfony command is a command-line script.

Sign up to request clarification or add additional context in comments.

1 Comment

If you configure your web server to be accessible locally, you can have the command line call an APC cache clear URL with curl or equivalent.
2

You just have to create your own custom task.

./symfony generate:task your_task_name 

In this task (in the lib folder) you just have to run something like

protected function execute($arguments = array(), $options = array()) { // Run your own apc cache // ... /// Then run the cache:clear $this->runTask('cache:clear'); } 

4 Comments

In our system the command symfony cache:clear is called on a large number of applications in a centralized manner, so it is important that I can overwrite the behavior of the cache:clear. Adding new tasks would not solve the problem, unfortunately.
@francescostablum but you won't have many others options, as I said.
Actually, I discovered that I can listen to an event: $this->dispatcher->connect('task.cache.clear', array('ClearAPCCache','clearCache')); -- remains the problem that is not possibile to clear the APC cache from a command-line task.
because APC cache is related to the web server process, while the symfony command is a command-line script. This is what I understood from my experiments. Not sure it's 100% correct

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.