Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Notify event when clearing cache #1884

Closed
Koc opened this Issue · 12 comments

6 participants

@Koc
Koc commented

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
Collaborator

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

@Problematic

+1 to that

@Koc
Koc commented

@lsmith77, yes, like cache warming.

@fabpot
Owner

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
@avalanche123

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
Collaborator

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

@Koc

+1 for cache_clearer tag

@fabpot fabpot reopened this
@fabpot
Owner

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

@lsmith77
Collaborator

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
Owner

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

@pulzarraider

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 fabpot referenced this issue from a commit
@fabpot fabpot 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.
05285e4
@Koc

so it done

@Koc Koc closed this
@fabpot fabpot referenced this issue from a commit
@fabpot fabpot 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
c1bd3b5
@mmucklo mmucklo referenced this issue from a commit
@fabpot fabpot 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.
9ecd7aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.