Notify event when clearing cache #1884

Closed
Koc opened this Issue Aug 1, 2011 · 12 comments

Comments

Projects
None yet
6 participants
@Koc
Contributor

Koc commented Aug 1, 2011

Sometimes we need clear additional data, for example APC user-cache. I think better create listeners for clearing additional cache instead of commands like apc:clear

@lsmith77

This comment has been minimized.

Show comment
Hide comment
@lsmith77

lsmith77 Aug 1, 2011

Contributor

so the purpose would be that app/console cache:clear would allow plugging in additional services that would be triggered via some event?

Contributor

lsmith77 commented Aug 1, 2011

so the purpose would be that app/console cache:clear would allow plugging in additional services that would be triggered via some event?

@Problematic

This comment has been minimized.

Show comment
Hide comment
@Problematic

Problematic Aug 1, 2011

+1 to that

+1 to that

@Koc

This comment has been minimized.

Show comment
Hide comment
@Koc

Koc Aug 1, 2011

Contributor

@lsmith77, yes, like cache warming.

Contributor

Koc commented Aug 1, 2011

@lsmith77, yes, like cache warming.

@fabpot

This comment has been minimized.

Show comment
Hide comment
@fabpot

fabpot Sep 28, 2011

Member

The console component has no dependency on the event listener and I don't want to add it. You can however extends the built-in cache:clear command to add your own logic. Or you can create a "meta" command that calls other commands. Last but not the least, remember that commands are like controllers; they should not contain any logic.

Member

fabpot commented Sep 28, 2011

The console component has no dependency on the event listener and I don't want to add it. You can however extends the built-in cache:clear command to add your own logic. Or you can create a "meta" command that calls other commands. Last but not the least, remember that commands are like controllers; they should not contain any logic.

@fabpot fabpot closed this Sep 28, 2011

@avalanche123

This comment has been minimized.

Show comment
Hide comment
@avalanche123

avalanche123 Sep 28, 2011

Contributor

you could make the cache clear console command notify event dispatcher manually as that is all part of the framework, and not introduce dependency in the component itself, no?

Contributor

avalanche123 commented Sep 28, 2011

you could make the cache clear console command notify event dispatcher manually as that is all part of the framework, and not introduce dependency in the component itself, no?

@lsmith77

This comment has been minimized.

Show comment
Hide comment
@lsmith77

lsmith77 Sep 28, 2011

Contributor

why not go in a similar direction as cache warmers .. just add cache_clearer services that are registered via a tag.

Contributor

lsmith77 commented Sep 28, 2011

why not go in a similar direction as cache warmers .. just add cache_clearer services that are registered via a tag.

@Koc

This comment has been minimized.

Show comment
Hide comment
@Koc

Koc Sep 28, 2011

Contributor

+1 for cache_clearer tag

Contributor

Koc commented Sep 28, 2011

+1 for cache_clearer tag

@fabpot fabpot reopened this Sep 28, 2011

@fabpot

This comment has been minimized.

Show comment
Hide comment
@fabpot

fabpot Sep 28, 2011

Member

ok, reopening this issue as @lsmith77 suggestion is a good idea.

Member

fabpot commented Sep 28, 2011

ok, reopening this issue as @lsmith77 suggestion is a good idea.

@lsmith77

This comment has been minimized.

Show comment
Hide comment
@lsmith77

lsmith77 Sep 28, 2011

Contributor

btw .. my first reply was because I thought you had closed #1929
so i guess the result of this ticket means that if at all, we will consider adding special tags on a case by case basis.

Contributor

lsmith77 commented Sep 28, 2011

btw .. my first reply was because I thought you had closed #1929
so i guess the result of this ticket means that if at all, we will consider adding special tags on a case by case basis.

@fabpot

This comment has been minimized.

Show comment
Hide comment
@fabpot

fabpot Sep 28, 2011

Member

@lsmith77: yes. so, #1929 should be closed.

Member

fabpot commented Sep 28, 2011

@lsmith77: yes. so, #1929 should be closed.

@pulzarraider

This comment has been minimized.

Show comment
Hide comment
@pulzarraider

pulzarraider Oct 28, 2011

Contributor

I've experimented with APC a bit today. Am I right, that APC can't be cleared from cli? APC has cli mode disabled by default, but even if I've enabled it, I was not able to access the cache items created from web interface.

So if am I right, the APC clearing command (or notify event) should call some URL which will clear APC from web interface.

Contributor

pulzarraider commented Oct 28, 2011

I've experimented with APC a bit today. Am I right, that APC can't be cleared from cli? APC has cli mode disabled by default, but even if I've enabled it, I was not able to access the cache items created from web interface.

So if am I right, the APC clearing command (or notify event) should call some URL which will clear APC from web interface.

fabpot added a commit that referenced this issue Dec 19, 2011

merged branch dustin10/cache-clearers (PR #2857)
Commits
-------

3ae976c fixed CS
84ad40d added cache clear hook

Discussion
----------

[Cache][2.1] Added cache clear hook

Allows bundles to hook into the `cache:clear` command by using the `kernel.cache_clearer` tag instead of using the `event_dispatcher` service.

See #1884

Bug fix: No
Feature addition: Yes
Backwards compatibility break: No
Symfony2 tests pass: Yes
Fixes the following tickets: #1884
References the following tickets: #1884

---------------------------------------------------------------------------

by dustin10 at 2011/12/16 11:03:54 -0800

Rebased to squash all commits into one.

---------------------------------------------------------------------------

by lsmith77 at 2011/12/17 05:27:29 -0800

@fabpot: we figured that priorities wouldn't be needed for cleaning .. haven't tested the PR, but conceptually it looks good to me and aside from the priority stuff its modeled after the cache warners.

---------------------------------------------------------------------------

by dustin10 at 2011/12/19 09:46:26 -0800

@fabpot Updated to pass cache dir to `clear` method.

---------------------------------------------------------------------------

by dustin10 at 2011/12/19 10:02:21 -0800

@stof and @fabpot Another thought I just had. Should the `$this->getContainer()->get('cache_clearer')->clear($realCacheDir);` call in the `CacheClearCommand` be done before the warming?

---------------------------------------------------------------------------

by stof at 2011/12/19 10:03:59 -0800

indeed. the clearing should be done before the warming.

---------------------------------------------------------------------------

by dustin10 at 2011/12/19 10:19:28 -0800

Squashed all commits into one. Let me know if there is anything else.

---------------------------------------------------------------------------

by dustin10 at 2011/12/19 10:31:50 -0800

Fixed extra lines.
@Koc

This comment has been minimized.

Show comment
Hide comment
@Koc

Koc Dec 19, 2011

Contributor

so it done

Contributor

Koc commented Dec 19, 2011

so it done

@Koc Koc closed this Dec 19, 2011

fabpot added a commit that referenced this issue Mar 25, 2013

merged branch fabpot/console-dispatcher (PR #7466)
This PR was merged into the master branch.

Discussion
----------

Console dispatcher

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #3889, #6124
| License       | MIT
| Doc PR        | symfony/symfony-docs#2352

refs #1884, #1929

This is an alternative implementation for adding events to console applications.

This implementation has the following features:

* Available for anyone using the Console component and it is not tied to
  FrameworkBundle (this is important as one thing we are trying to solve is
  email sending from a command, and frameworks like Silex using the Console
  component needs a solution too);

* Non-intrusive as the current code has not been changed (except for renaming
  an internal variable that was wrongly named -- so that's not strictly needed
  for this PR)

* The new DispatchableApplication class also works without a dispatcher,
  falling back to the regular behavior. That makes easy to create applications
  that can benefit from a dispatcher when available, but can still work
  otherwise.

* Besides the *before* and *after* events, there is also an *exception* event
  that is dispatched whenever an exception is thrown.

* Each event is quite powerful and can manipulate the input, the output, but
  also the command to be executed.

Commits
-------

4f9a55a refactored the implementation of how a console application can handle events
4edf29d added helperSet to console event objects
f224102 Added events for CLI commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment