RedisTemplate执行lua脚本在Redis集群模式下报错EvalSha is not supported in cluster environment.
异常信息:
1 | org.springframework.dao.InvalidDataAccessApiUsageException: EvalSha is not supported in cluster environment. |
执行方法,集群下报错:
1 | public boolean unlock(String key, String value) { |
解决方案
原因:spring自带的执行脚本方法中,集群模式直接抛出不支持执行脚本的异常,所以只能拿到原redis的connection来执行脚本。
1 | public boolean unlock(String key, String value) { |
参考文档: