public boolean acquireLock(String key, boolean exclusive, long millis) {
ReentrantReadWriteLock lock = getLock(key);
try {
if (exclusive) {
return lock.writeLock().tryLock(millis, TimeUnit.MILLISECONDS);
} else {
return lock.readLock().tryLock(millis, TimeUnit.MILLISECONDS);
}
} catch (InterruptedException e) {
log.warn("Thread insterrupted while trying to acquire lock", e);