# redis-tools-starter **Repository Path**: ellipse/redis-tools-starter ## Basic Information - **Project Name**: redis-tools-starter - **Description**: springboot-starter for redis-tools - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-10 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # spring-boot-starter-redis-tools # 使用默认配置 ```java @SpringBootApplication @RestController public class AutoConfigApplication { @Autowired private StringRedisTemplate redisTemplate; @Resource private RedisCache redisCache; @PostConstruct private void init() { for (int i = 0; i < 100; i++) { redisCache.getFilter().put(String.valueOf(i)); } } @GetMapping("/{id:\\d+}") public String index(@PathVariable String id) { String cacheKey = "cache:test:" + id; return redisCache.scope(id) .hit(ctx -> redisTemplate.opsForValue().get(cacheKey)) .miss(ctx -> { System.out.println("miss"); try { TimeUnit.MILLISECONDS.sleep(100 + ThreadLocalRandom.current().nextInt(100)); } catch (InterruptedException ignore) { } String value = new Date().toString(); redisTemplate.opsForValue().set(cacheKey, value); return value; }).get(); } public static void main(String[] args) { SpringApplication.run(AutoConfigApplication.class, args); } } ```