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()方法中从数据库获取所有数据并添加到学生缓存中
但是,当使用findstudentsbystudentnameanddresses()方法基于某些条件(name/address1/address2/address3)搜索数据时,它从db而不是缓存中获取数据。
注意:缓存时未添加键,因为搜索条件中有4个字段(name/address1/address2/address3),这些字段是条件字段,这意味着有时只有address1会在搜索条件中,有时address1+address2或有时所有address1+address2+address3字段中,我希望根据name和address3获取精确匹配可用地址。
2条答案
按热度按时间jdg4fx2g1#
您是否在配置类中添加了@enablecaching注解
7vux5j2d2#
尝试添加这样的配置
希望有用