如何清除Play Framework 2.1中的所有缓存

问题描述:

因此,我正在使用Play的内置缓存API,如下所示: http://www.playframework.com/documentation/2.1.x/JavaCache

So I'm using Play's built in cache API as seen here: http://www.playframework.com/documentation/2.1.x/JavaCache

在我的代码中,我已经将缓存设置为每10分钟过期一次.我也在使用会话缓存样式.

In my code I've already set the cache to expire every 10 minutes. I am also using the session cache style.

所以我的主要问题是,由于要跟踪所有缓存确实非常困难,如何清除所有缓存?我知道使用Play的默认缓存是最少的,但目前对我来说效果很好.我只希望能够偶尔清除一次缓存,以防万一进行了太多会话,并且在我的代码中的某个地方堆积了缓存.

So my main question is, since it's gonna be really hard to keep track of all cache, how do I clear all of the cache? I know that using Play's default cache is minimal but it's working perfectly for me at this point. I just want the ability to clear the cache once in awhile just in case too many sessions are made and somewhere in my code it's piling up the caches.

The Play Java API does not provide a way to clear the whole cache.

您将必须使用自己的缓存插件,或扩展

You'll have to use your own cache plugin, or extends the existing one to provide this feature.