我有一個python後端,在前面使用varnish 3.0.7作爲api工作。我希望能夠從我的Python應用程序中清除清漆緩存 - e.i.在一些文件被更新之後。清除python中的所有Varnish緩存
我一直試圖從本教程中清除https://www.varnish-cache.org/docs/3.0/tutorial/purging.html 但它只清除一個對象。
我知道我可以重新啓動清漆,但有什麼辦法刪除所有緩存的對象嗎?
我有一個python後端,在前面使用varnish 3.0.7作爲api工作。我希望能夠從我的Python應用程序中清除清漆緩存 - e.i.在一些文件被更新之後。清除python中的所有Varnish緩存
我一直試圖從本教程中清除https://www.varnish-cache.org/docs/3.0/tutorial/purging.html 但它只清除一個對象。
我知道我可以重新啓動清漆,但有什麼辦法刪除所有緩存的對象嗎?
最後我用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'])
工作就像一個魅力...
你可以從varnishadmin(varnishadm「ban req.url〜/」)做到這一點,我不確定是否有程序化的方式來滿足你的需求。
更新: 你可以看看該項目https://github.com/justquick/python-varnish(沒有自己嘗試過)。