public class Student {
    public int studentName;
    public String Addr1;
    public String Addr2;
    public String Addr2;
    //getter setter
}

I have one repository class which contains following methods
class StudentRepoImpl{
   @Cacheable(value = "Students")
   public List<Students> findAllStudents() {
     //fetching all cust and putting in the Students cache
   }

   @Cacheable(value = "Students")
   public List<Students> findStudentsBystudentNameAndAddresses() {
     //fetching all cust data by **Name/Address1/Address2/Address3** basis of field available studentName/Address1/Address2/Address3 and putting in Student table
   }

}


电流输出


从数据库中获取所有数据,并在findAllStudents()方法中添加学生缓存
但是,在使用findStudentsBystudentNameAndAddresses()方法基于某些条件(名称/地址1 /地址2 /地址3)搜索数据时,它是从数据库而不是缓存中获取数据。


注意:缓存时未添加密钥,因为搜索条件中有4个字段(名称/地址1 /地址2 /地址3),而这些是条件字段,这意味着有时只有地址1处于搜索条件中,或者有时地址1+地址2或有时是地址1+地址2 + Address3字段,我想根据名称和可用地址获取完全匹配。

最佳答案

您是否在配置类中添加了@EnableCaching批注

07-28 02:11
查看更多