Search in sources :

Example 21 with Person

use of com.xiaolyuh.entity.Person in project spring-boot-student by wyh-spring-ecosystem-student.

the class PersonServiceImpl method findOne.

/**
 * Cacheable
 * value:缓存key的前缀。
 * key:缓存key的后缀。
 * sync:设置如果缓存过期是不是只放一个请求去请求数据库,其他请求阻塞,默认是false。
 */
@Override
@Cacheable(value = "people#${select.cache.timeout:1800}#${select.cache.refresh:600}", key = "#person.id", sync = true)
public // 3
Person findOne(Person person, String a, String[] b, List<Long> c) {
    Person p = personRepository.findOne(person.getId());
    System.out.println("为id、key为:" + p.getId() + "数据做了缓存");
    System.out.println(redisTemplate);
    return p;
}
Also used : Person(com.xiaolyuh.entity.Person) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

Person (com.xiaolyuh.entity.Person)21 Field (java.lang.reflect.Field)6 Test (org.junit.Test)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 Expression (org.springframework.expression.Expression)6 ExpressionParser (org.springframework.expression.ExpressionParser)6 SpelExpressionParser (org.springframework.expression.spel.standard.SpelExpressionParser)6 StandardEvaluationContext (org.springframework.expression.spel.support.StandardEvaluationContext)6 Cacheable (org.springframework.cache.annotation.Cacheable)5 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 Transactional (org.springframework.transaction.annotation.Transactional)2 GetMapping (org.springframework.web.bind.annotation.GetMapping)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 SentinelResource (com.alibaba.csp.sentinel.annotation.SentinelResource)1 Location (com.xiaolyuh.entity.Location)1 CsvExportUtil (com.xiaolyuh.utils.CsvExportUtil)1 ExcelExportUtils (com.xiaolyuh.utils.ExcelExportUtils)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1