2013-10-10 39 views
2

我想刪除一個字符串前綴我所有的緩存條目,但我的代碼返回:主義緩存的Symfony2 deleteByPrefix

Fatal error: Call to undefined method Doctrine\Common\Cache\FilesystemCache::deleteByPrefix() 

和我的代碼是

$deleted = $cachemanager->deleteByPrefix('catalog_'); 

等,其中我查了一下:進入教條http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/caching.html#deleting的文件。

我需要清除緩存,因爲控制器,而不是從CLI ...

是否有人來替代這種方法「deleteByPrefix()」?

+0

你的緩存管理器實際上是一個'FilesystemCache'對象具有[無方法(HTTP:// API .nellafw.org/class-Doctrine.Common.Cache.Cache.html)'deleteByPrefix'。使你的'$ cachemanager'成爲一個對象的實例,它將* wrap * doctrine的緩存並添加你的自定義方法 – Touki

回答

0

最後,我來使用Zend框架緩存束,誰允許由前綴刪除...

0

您可以使用命名空間。這將需要重新組織你的緩存。或者您可以編寫自己的實現(擴展Doctrine \ Common \ Cache \ FilesystemCache),它將實現deleteByPrefix(),但您將使用簡單地切換緩存提供程序的功能。

+0

在使用命名空間時,我該如何刪除具有特定命名空間的所有條目?沒有'deleteAll()'功能... – pbenard

+0

你不想說:「你會***失去***切換緩存提供者的能力」嗎? –