如何使用Spring Boot从ehcache 3检索值

时间:2019-07-08 11:04:34

标签: spring-boot ehcache-3

如何使用ehcache3从缓存中检索所有值。我见过     文档并尝试使用链接中给出的示例-     https://www.baeldung.com/spring-boot-ehcache

 I followed this link as well - 
 http://www.ehcache.org/documentation/3.1/107.html

 I didn't found any concrete example how to use cachemanaget to retrive 
 elements from a specific cache.



These are the dependencies added in the pom -

   <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-cache</artifactId>
    </dependency>
    <dependency>
        <groupId>org.ehcache</groupId>
        <artifactId>ehcache</artifactId>
        <version>3.6.2</version>
    </dependency>
    <dependency>
        <groupId>javax.cache</groupId>
        <artifactId>cache-api</artifactId>
    </dependency>

   This is my method -

    @Cacheable(value = "idAndEmail", key="#idEmail")
public HashMap<String, String> 
     getidAndEmail(HashMap<String,String> idEmail) {
    System.out.println("caching id and email, next refresh happens 
           after configured time");

    return idEmail;

}

  Here caching works but how to fetch the values based on the keys ?
  Help would be really appreciated.

0 个答案:

没有答案