缓存在java spring中逐出一个对象

时间:2017-12-04 12:08:58

标签: java spring spring-mvc caching

我正在尝试缓存一个对象列表,让我们说“订单”。它完美地缓存它。

将新对象放入缓存列表中我正在做的是这个;

    cacheManager.getCacheNames().parallelStream().forEach(name -> cacheManager.getCache(name).put("order", order));

从我所做的缓存中驱逐该特定订单;

    cacheManager.getCacheNames().parallelStream().forEach(name -> cacheManager.getCache(name).evict(orderId));

但是,逐出去并不适合我。

如何删除/更新缓存中过时的对象?有没有办法迭代缓存,直到我得到所需的对象并更新它。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

要将对象放入缓存,您应该使用<!DOCTYPE html> <html> <head> <style> .mystyle { width: 300px; height: 50px; background-color: coral; color: white; font-size: 25px; } .mystyle1 { width: 100px; height: 100px; background-color: black; color: coral; font-size: 30px; } </style> </head> <body> <p>Click the button to change the style class from DIV.</p> <button onclick="myFunction()">Try it</button> <div id="myDIV" class="mystyle"> I am a DIV element </div> <script> function myFunction() { var x = document.getElementById("myDIV"); if (x.classList.contains("mysyle")) { x.classList.replace("mystyle", "mystyle1"); } if (x.classList.contains("mysyle1")) { x.classList.replace("mystyle1", "mystyle"); } } </script> </body> </html>而不是字符串值orderId

"order"
相关问题