# springboot-redis **Repository Path**: xuyaxu/springboot-redis ## Basic Information - **Project Name**: springboot-redis - **Description**: Spring Boot整合Redis的常规使用,包含秒杀案例。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-08-22 - **Last Updated**: 2023-02-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README
使用Redisson实现Redis分布式锁功能
优点:简介实用,是目前较流行解决方案。
Request processing failed; nested exception is java.lang.IllegalMonitorStateException: attempt to unlock lock, not locked by current thread by node id: 7b902e4a-2ddc-43b9-a58d-e44e14191c6c thread-id: 74
这个异常是因为:解锁需要创建锁的线程进行解锁,否则就会报这个异常,
而我们在代码中设置了锁的过期时间,如果业务耗时超过了设置的过期时间,那再去解锁就会报这个错。
1. 将锁的过期时间延长稍大于业务耗时时间。
2. 做释放锁操作的时候判断一下是否已成功加锁。