如何更新特定的缓存路由? [英] How to update specific cached route?

查看:50
本文介绍了如何更新特定的缓存路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行Symfony2应用,并且对缓存存在疑问.

I am running a Symfony2 app and I have a question about caching.

在回答上有评论在SO中表示:

There is a comment on an answer here in SO that says:

您可以创建一个仅更新此缓存路线的命令.或者也许可以考虑使用新注册内核事件的内核事件监听器如果您可以承受性能影响,则可以在每个请求上进行路由.

you could create a command that only updates this one cached route. or maybe consider using a kernel event listener that newly registers the route on every request if you can afford the performance impact.

我怎么只更新这条缓存的路由?

How could I update only this one cached route?

推荐答案

缓存的路由存储在哪里?

用于url匹配/生成的缓存类可以在 app/cache/environment 中找到,它们分别称为 appEnvironmentUrlGenerator.php appEnvironmentUrlGenerator.php 环境"是 dev prod ,..等之一.

The cache classes for url matching/generation can be found in app/cache/environment and are called appEnvironmentUrlGenerator.php and appEnvironmentUrlGenerator.php with "environment" being one of dev,prod, .. etc.

API参考:

http://api.symfony.com/2.3/Symfony/组件/路由/匹配器/UrlMatcher.html http://api.symfony.com/2.3/Symfony/Component/Routing/Generator/UrlGenerator.html

它如何工作?

路由器服务在构建时会收到一个url-matcher和一个url-generator.然后,这些将在路由器的 match() generate()方法中使用.

The router service receives a url-matcher and a url-generator when being constructed. Those are then being used inside the match() and generate() methods of the router.

https://github.com/symfony/symfony/blob/2.3/src/Symfony/Component/Routing/Router.php

要预热缓存,请RoutingCacheWarmer 使用路由器的 warmUp()方法(如果它实现了

For warming up the cache the RoutingCacheWarmer uses the router's warmUp() method (if it implements WarmableInterface).

这篇关于如何更新特定的缓存路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆