All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nepxion.aquarius.lock.redis.impl.RedisLockDelegateImpl Maven / Gradle / Ivy

Go to download

Nepxion Aquarius is a list of distribution components based on Redis + Zookeeper with Nepxion Matrix AOP framework

There is a newer version: 2.0.13
Show newest version
package com.nepxion.aquarius.lock.redis.impl;

/**
 * 

Title: Nepxion Aquarius

*

Description: Nepxion Aquarius

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Haojun Ren * @version 1.0 */ import org.aopalliance.intercept.MethodInvocation; import org.redisson.api.RLock; import org.springframework.beans.factory.annotation.Autowired; import com.nepxion.aquarius.lock.LockDelegate; import com.nepxion.aquarius.lock.LockExecutor; import com.nepxion.aquarius.lock.entity.LockType; public class RedisLockDelegateImpl implements LockDelegate { @Autowired private LockExecutor lockExecutor; @Override public Object invoke(MethodInvocation invocation, LockType lockType, String key, long leaseTime, long waitTime, boolean async, boolean fair) throws Throwable { RLock lock = null; try { lock = lockExecutor.tryLock(lockType, key, leaseTime, waitTime, async, fair); if (lock != null) { return invocation.proceed(); } } finally { lockExecutor.unlock(lock); } return null; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy