# redis-tools **Repository Path**: ellipse/redis-tools ## Basic Information - **Project Name**: redis-tools - **Description**: Redis 布隆过滤器 & 分布式锁 & springboot-starter - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2020-06-02 - **Last Updated**: 2021-05-25 ## 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); } } ``` # 不使用springboot-starter [redis-tools/README.md](./redis-tools/README.md)