从python中清除所有清漆缓存

2024-05-15 11:24:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个python后端,作为api,前面是Varnish 3.0.7。时不时地,我希望能够在一些文档更新后,从我的python应用程序e.I.中清除varnish缓存。在

我一直在尝试从本教程中清除https://www.varnish-cache.org/docs/3.0/tutorial/purging.html 但它只清除一个物体。在

我知道我可以重新启动varnish,但是有没有办法删除所有缓存对象?在


Tags: 文档httpsorgapi应用程序docscachehtml
2条回答

你可以从varnishadmin(varnishadm”ban“来做请求url~/“),我不确定是否有编程方式满足您的需求。在

更新: 你可以看看这个项目https://github.com/justquick/python-varnish(我没试过)。在

最后我使用了https://pypi.python.org/pypi/python-varnish

from varnish import VarnishManager as varnish_manager
manager = varnish_manager(('localhost:6082',))
manager.run('stop', secret=current_app.config['VARNISH_SECRET'])
manager.run('start', secret=current_app.config['VARNISH_SECRET'])

像个魔术师一样工作。。。在

相关问题 更多 >