Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Distributed locking between Java and Nodejs application using Redis

$
0
0

In my current project I have two deal with two processes one written in Java another in NodeJs.Both the application does some computation and stores some data in Redis, but for some consistency reason only one of them should be accessing the Redis resources at a time.After reading the official documentation of Redis(https://redis.io/topics/distlock), I thought to use Redlock algorithm for distributed locking.I found that when I use node-redlock(recommended library for NodeJS) for locking a key 'redis-lock' it is stored with a random value and expiry time in Redis, whereas on using Redisson(recommended library for Java) for locking the same 'redis-lock; key it stores a hash.I am facing some errors when the Java process has already created and locked the key and NodeJs process tries to access it because it expects the key to be of type simple string and not a hash.I don't understand why the two libraries implementing the same algorithm uses different data-structures to lock a key.Please help me fixing the issue.Otherwise is there any other simple solution to implement the distributed lock between the two apps (I know I can use a DB as well, but wanted to use Redis as it's already being used in the applications context)?Thank you.


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>