放在实现类中:
第一种方式key = "'user_id_'+#id",unless = "#result == null")
@Cacheable(value = "user",key = "'user_id_'+#id",unless = "#result == null")
public User selectByPrimaryKey(Integer id) {
return userMapper.selectByPrimaryKey(id);
}
可以读到参数值Integer id
第二种方式key = "'user_id_'+#p0",unless = "#result == null")
@Cacheable(value = "user",key = "'user_id_'+#id",unless = "#result == null")
public User selectByPrimaryKey(Integer id) {
return userMapper.selectByPrimaryKey(id);
}
也可以读到参数值Integer id
放在接口上:
第一种方式可以读到Integer id值
@Cacheable(value = "user",key = "'user_id_'+#p0",unless = "#result == null")
User selectByPrimaryKey(Integer id);
--接口数据
--Redis缓存数据
第二种方式读不到Integer id值,值是null,
@Cacheable(value = "user",key = "'user_id_'+#id",unless = "#result == null")
User selectByPrimaryKey(Integer id);