Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedisLockExecutorImpl 获取锁的实现,可不用作缓存 #8

Open
ihenjoy opened this issue Apr 25, 2022 · 2 comments
Open

RedisLockExecutorImpl 获取锁的实现,可不用作缓存 #8

ihenjoy opened this issue Apr 25, 2022 · 2 comments

Comments

@ihenjoy
Copy link

ihenjoy commented Apr 25, 2022

image
这里可以不用作本地缓存,因为Redission 内部的重入本身就是按客户端id+线程id来判断的,这里加了本地缓存,如果业务key很多的话,就可能这里的内存占用会很大

@HaojunRen
Copy link
Member

如果不做缓存,Redission每次去获取锁,都会new Redission Lock对象,对于吞吐量很大的服务,一秒几千上万次调用,那岂不是一秒也要创建出成千上万个对象出来?数据应该都正确的,重入锁应该需要重复利用,缓存起来吧?

@HaojunRen
Copy link
Member

参考源码,每次getLock都是new RedissonLock

public class Redisson implements RedissonClient {
...
    @Override
    public RLock getLock(String name) {
        return new RedissonLock(commandExecutor, name);
    }
...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants