Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Notify event when clearing cache #1884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Notify event when clearing cache #1884

Koc opened this issue Aug 1, 2011 · 12 comments

Comments

@Koc
Copy link
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
Copy link
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
Copy link

+1 to that

@Koc
Copy link
Contributor Author

Koc commented Aug 1, 2011

@lsmith77, yes, like cache warming.

@fabpot
Copy link
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 as completed Sep 28, 2011
@avalanche123
Copy link
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?

@lsmith77
Copy link
Contributor

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

@Koc
Copy link
Contributor Author

Koc commented Sep 28, 2011

+1 for cache_clearer tag

@fabpot fabpot reopened this Sep 28, 2011
@fabpot
Copy link
Member

fabpot commented Sep 28, 2011

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

@lsmith77
Copy link
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.

@fabpot
Copy link
Member

fabpot commented Sep 28, 2011

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

@pulzarraider
Copy link
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.

fabpot added a commit that referenced this issue Dec 19, 2011
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
Copy link
Contributor Author

Koc commented Dec 19, 2011

so it done

@Koc Koc closed this as completed Dec 19, 2011
fabpot added a commit that referenced this issue Mar 25, 2013
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
Projects
None yet
Development

No branches or pull requests

6 participants