Skip to content
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

Support REST controller invalidation #23

Open
ddeboer opened this issue Jan 3, 2014 · 7 comments
Open

Support REST controller invalidation #23

ddeboer opened this issue Jan 3, 2014 · 7 comments
Labels

Comments

@ddeboer
Copy link
Member

ddeboer commented Jan 3, 2014

Add a controller annotation and YML configuration option that invalidate all methods in a controller when they and their routes names follow a convention, such as the of the FOSRestBundle.

@dbu
Copy link
Contributor

dbu commented Jan 17, 2014

@lsmith77 do you have inputs for this idea? sounds like a cool RAD way of doing things.

@lsmith77
Copy link
Member

can you elaborate a bit more on how this is supposed to work?

@ddeboer
Copy link
Member Author

ddeboer commented Jan 17, 2014

Maybe have an annotation @EnableInvalidation annotation that when added to a controller class, would enable cache invalidation for all controllers in it (caching headers themselves could be set with SensioFrameworkExtraBundle's @Cache annotation). Each unsafe request to one of the controllers then automatically invalidates the cache for that controller's safe equivalent. So:

POST /things invalidates GET /things
PUT/DELETE /things/123 invalidates GET /things/123

etc.

For determining invalidation paths, we could:

  • look at route names, which works with predictably named routes (such as FOSRestBundle's automatic route generation)
  • look at the paths, which only works with RESTful paths.

@ddeboer
Copy link
Member Author

ddeboer commented Nov 29, 2014

The only problem I see here is that we would need to check whether the route actually exists: so if put_article triggers an invalidation, get_articles should not be invalidated if that route didn’t exist. Or is it now safe to use getRouteCollection() for this?

@stof
Copy link
Member

stof commented Dec 2, 2014

Or is it now safe to use getRouteCollection() for this?

no it is not. getRouteCollection triggers the route loading, which is not a good idea in production (unless you build your own cache on top of it to avoid redoing it many times of course)

@dbu
Copy link
Contributor

dbu commented Dec 2, 2014

we face the same problem with the route collection in #161 - what would be the clean way to do such things?

@stof
Copy link
Member

stof commented Dec 3, 2014

@dbu Building a service which extracts the informations from the RouteCollection and then caches them. You can look at the way FOSRestBundle does it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants