Java Code Examples for org.redisson.api.RedissonClient#getLock()

The following examples show how to use org.redisson.api.RedissonClient#getLock() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RedissonTest.java    From java-tutorial with MIT License 6 votes vote down vote up
@Test
public void test() throws InterruptedException {
    Config config = new Config();
    SingleServerConfig singleServerConfig = config.useSingleServer();
    singleServerConfig.setAddress(redssionProperties.getAddress());
    singleServerConfig.setPassword(redssionProperties.getPassword());

    RedissonClient redissonClient = RedisUtils.getInstance().getRedisson(config);
    RBucket<Object> rBucket = RedisUtils.getInstance().getRBucket(redissonClient, "key");

    System.out.println(rBucket.get());
    while (true) {
        RLock lock = redissonClient.getLock("com.lock");
        lock.tryLock(0, 1, TimeUnit.SECONDS);
        try {
            System.out.println("执行");
        } finally {
            lock.unlock();
        }
    }


}
 
Example 2
Source File: RedissLockDemo.java    From spring-boot-seckill with GNU General Public License v2.0 6 votes vote down vote up
/**
    * 可重入锁(Reentrant Lock) 
    * Redisson的分布式可重入锁RLock Java对象实现了java.util.concurrent.locks.Lock接口,同时还支持自动过期解锁
    * @param redisson
    */
public void testReentrantLock(RedissonClient redisson) {
	RLock lock = redisson.getLock("anyLock");
	try {
		// 1. 最常见的使用方法
		// lock.lock();
		// 2. 支持过期解锁功能,10秒钟以后自动解锁, 无需调用unlock方法手动解锁
		// lock.lock(10, TimeUnit.SECONDS);
		// 3. 尝试加锁,最多等待3秒,上锁以后10秒自动解锁
		boolean res = lock.tryLock(3, 10, TimeUnit.SECONDS);
		if (res) { // 成功
			// do your business
		}
	} catch (InterruptedException e) {
		e.printStackTrace();
	} finally {
		lock.unlock();
	}
}
 
Example 3
Source File: RedissLockDemo.java    From spring-boot-seckill with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 联锁(MultiLock)
 * Redisson的RedissonMultiLock对象可以将多个RLock对象关联为一个联锁,每个RLock对象实例可以来自于不同的Redisson实例
 * @param redisson1
 * @param redisson2
 * @param redisson3
 */
public void testMultiLock(RedissonClient redisson1,RedissonClient redisson2, RedissonClient redisson3){  
    RLock lock1 = redisson1.getLock("lock1");  
    RLock lock2 = redisson2.getLock("lock2");  
    RLock lock3 = redisson3.getLock("lock3");  
    RedissonMultiLock lock = new RedissonMultiLock(lock1, lock2, lock3);  
    try {  
        // 同时加锁:lock1 lock2 lock3, 所有的锁都上锁成功才算成功。  
        lock.lock();  
        // 尝试加锁,最多等待100秒,上锁以后10秒自动解锁  
        boolean res = lock.tryLock(100, 10, TimeUnit.SECONDS);  
        if (res) {
			// do your business
		}
    } catch (InterruptedException e) {  
        e.printStackTrace();  
    } finally {  
        lock.unlock();  
    }  
}
 
Example 4
Source File: RedissLockDemo.java    From spring-boot-seckill with GNU General Public License v2.0 6 votes vote down vote up
/**
 *  红锁(RedLock)
 *  Redisson的RedissonRedLock对象实现了Redlock介绍的加锁算法。该对象也可以用来将多个RLock对象关联为一个红锁,每个RLock对象实例可以来自于不同的Redisson实例
 * @param redisson1
 * @param redisson2
 * @param redisson3
 */
public void testRedLock(RedissonClient redisson1,RedissonClient redisson2, RedissonClient redisson3){  
    RLock lock1 = redisson1.getLock("lock1");  
    RLock lock2 = redisson2.getLock("lock2");  
    RLock lock3 = redisson3.getLock("lock3");  
    RedissonRedLock lock = new RedissonRedLock(lock1, lock2, lock3);  
    try {  
        // 同时加锁:lock1 lock2 lock3, 红锁在大部分节点上加锁成功就算成功。  
        lock.lock();  
        // 尝试加锁,最多等待100秒,上锁以后10秒自动解锁  
        boolean res = lock.tryLock(100, 10, TimeUnit.SECONDS);  
        if (res) {
			// do your business
		}
    } catch (InterruptedException e) {  
        e.printStackTrace();  
    } finally {  
        lock.unlock();  
    }  
}
 
Example 5
Source File: LockExamples.java    From redisson-examples with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    // connects to 127.0.0.1:6379 by default
    RedissonClient redisson = Redisson.create();
    
    RLock lock = redisson.getLock("lock");
    lock.lock(2, TimeUnit.SECONDS);

    Thread t = new Thread() {
        public void run() {
            RLock lock1 = redisson.getLock("lock");
            lock1.lock();
            lock1.unlock();
        };
    };

    t.start();
    t.join();

    lock.unlock();
    
    redisson.shutdown();
}
 
Example 6
Source File: RedissonRedLockTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test
public void testLockSuccess() throws IOException, InterruptedException {
    RedisProcess redis1 = redisTestMultilockInstance();
    RedisProcess redis2 = redisTestMultilockInstance();
    
    RedissonClient client1 = createClient(redis1.getRedisServerAddressAndPort());
    RedissonClient client2 = createClient(redis2.getRedisServerAddressAndPort());
    
    RLock lock1 = client1.getLock("lock1");
    RLock lock2 = client1.getLock("lock2");
    RLock lock3 = client2.getLock("lock3");
    
    testLock(lock1, lock2, lock3, lock1);
    testLock(lock1, lock2, lock3, lock2);
    testLock(lock1, lock2, lock3, lock3);
    
    client1.shutdown();
    client2.shutdown();
    
    assertThat(redis1.stop()).isEqualTo(0);
    assertThat(redis2.stop()).isEqualTo(0);
}
 
Example 7
Source File: RedissonLockTest.java    From redisson with Apache License 2.0 6 votes vote down vote up
@Test(expected = WriteRedisConnectionException.class)
public void testRedisFailed() throws IOException, InterruptedException {
    RedisRunner.RedisProcess master = new RedisRunner()
            .port(6377)
            .nosave()
            .randomDir()
            .run();

    Config config = new Config();
    config.useSingleServer().setAddress("redis://127.0.0.1:6377");
    RedissonClient redisson = Redisson.create(config);

    RLock lock = redisson.getLock("myLock");
    // kill RedisServer while main thread is sleeping.
    master.stop();
    Thread.sleep(3000);
    lock.tryLock(5, 10, TimeUnit.SECONDS);
}
 
Example 8
Source File: ShopifyJacksonDecoder.java    From shopify-api-java-wrapper with Apache License 2.0 5 votes vote down vote up
@Override
public Object decode(Response response, Type type) throws IOException
{
    Collection<String> shopifyApiCallLimitHeader = response.headers().get("HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT");

    String[] callLimitValues = shopifyApiCallLimitHeader.iterator().next().split("/");

    if(callLimitValues[0] != null && callLimitValues[0] != "")
    {
        Long createdCalls = Long.parseLong(callLimitValues[0]);

        Long remainingCalls = _shopifyRedissonManager.calculateAvalableCredits(createdCalls);

        RedissonClient redisson = _shopifyRedissonManager.getRedissonClient();

        // Lock per shopify store. The lock is distributed, so it will work for multiple threads and applications.
        RLock lock = redisson.getLock(_shopifyRedissonManager.getMyShopifyUrl());

        RAtomicLong remainingCreditsAtomic = redisson.getAtomicLong(_shopifyRedissonManager.getRemainingCreditsKey());
        RAtomicLong lastRequestTimeAtomic = redisson.getAtomicLong(_shopifyRedissonManager.getLastRequestTimeKey());

        remainingCreditsAtomic.set(remainingCalls);
        lastRequestTimeAtomic.set(System.currentTimeMillis());

        lock.unlock();
    }

    return super.decode(response, type);
}
 
Example 9
Source File: RedissonMultiLockTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testWaitAndLeaseTimeouts() throws IOException, InterruptedException {
    RedisProcess redis1 = redisTestMultilockInstance();
    
    Config config1 = new Config();
    config1.useSingleServer().setAddress(redis1.getRedisServerAddressAndPort());
    RedissonClient client = Redisson.create(config1);
    
    RLock lock1 = client.getLock("lock1");
    RLock lock2 = client.getLock("lock2");
    RLock lock3 = client.getLock("lock3");

    ExecutorService executor = Executors.newFixedThreadPool(10);
    AtomicInteger counter = new AtomicInteger();
    for (int i = 0; i < 10; i++) {
        executor.submit(() -> {
            RedissonMultiLock lock = new RedissonMultiLock(lock1, lock2, lock3);
            try {
                boolean res = lock.tryLock(-1, 10, TimeUnit.SECONDS);
                if (res) {
                    counter.incrementAndGet();
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
    }

    executor.shutdown();
    assertThat(executor.awaitTermination(1, TimeUnit.SECONDS)).isTrue();
    assertThat(counter.get()).isEqualTo(1);
}
 
Example 10
Source File: RedissonLockTest.java    From redisson with Apache License 2.0 5 votes vote down vote up
@Test
public void testInCluster() throws Exception {
    RedisRunner master1 = new RedisRunner().port(6890).randomDir().nosave();
    RedisRunner master2 = new RedisRunner().port(6891).randomDir().nosave();
    RedisRunner master3 = new RedisRunner().port(6892).randomDir().nosave();
    RedisRunner slave1 = new RedisRunner().port(6900).randomDir().nosave();
    RedisRunner slave2 = new RedisRunner().port(6901).randomDir().nosave();
    RedisRunner slave3 = new RedisRunner().port(6902).randomDir().nosave();

    ClusterRunner clusterRunner = new ClusterRunner()
            .addNode(master1, slave1)
            .addNode(master2, slave2)
            .addNode(master3, slave3);
    ClusterRunner.ClusterProcesses process = clusterRunner.run();

    Thread.sleep(5000);

    Config config = new Config();
    config.useClusterServers()
    .setLoadBalancer(new RandomLoadBalancer())
    .addNodeAddress(process.getNodes().stream().findAny().get().getRedisServerAddressAndPort());
    RedissonClient redisson = Redisson.create(config);

    RLock lock = redisson.getLock("myLock");
    lock.lock();
    assertThat(lock.isLocked()).isTrue();
    lock.unlock();
    assertThat(lock.isLocked()).isFalse();

    redisson.shutdown();
    process.shutdown();
}
 
Example 11
Source File: PurchaseOrderServiceImpl.java    From ChengFeng1.5 with MIT License 4 votes vote down vote up
@Transactional
    @Override
    public AssembleDetailVo joinExistsAssemble(Integer assembleId,Integer skuId,Integer count,Integer shippingId) {
        //加入已经存在的拼单
        Assemble assemble = assembleMapper.selectByPrimaryKey(assembleId);
        Objects.requireNonNull(assemble,"当前拼单不存在");
        if (assemble.getStatus()==0){
            throw new ParamException("当前拼单已经失效,无法加入当前拼单");
        }
        if (assemble.getStatus()==2){
            throw new ParamException("拼单人数已满,加入拼单失败");
        }
        checkSpellArguments(assemble.getProductId(),count);
        //使用分布式锁
        Config config = new Config();
        config.useSingleServer()
                .setAddress(RedisConstant.Redisson.REDIS_ADDRESS);
        RedissonClient redisson = Redisson.create(config);
        RLock lock = redisson.getLock(RedisConstant.Redisson.LOCK_SPELL_ORDER);
        boolean locked = false;
        try{
            log.info("尝试获取拼单锁");
            locked = lock.tryLock(10,TimeUnit.SECONDS);
            log.info("获取锁的状态:{}",locked);
            if(locked){
                User user=AuthenticationInfoUtil.getUser(userMapper,memcachedClient);
                AssembleItem assembleItem=new AssembleItem();
                assembleItem.setNickname(user.getNickname());
                assembleItem.setAvatar(user.getAvatar());
                assembleItem.setAssembleId(assembleId);
                assembleItemMapper.insert(assembleItem);
//                assemble.getAssembleItems().add(assembleItem);
                assemble.setStatus(2);//拼单完成,开始进入订单生效阶段
                assembleMapper.updateByPrimaryKeySelective(assemble);
                generateOrder(user,skuId,count,assemble,shippingId);

                //更新订单下的所有发货信息,异步操作
                this.rabbitTemplate.convertAndSend(UPDATE_ORDER_EXCHANGE,"",String.valueOf(assembleId));
                rabbitTemplate.convertAndSend(ChengfengConstant.RabbitMQ.UPDATE_ORDER_EXCHANGE,
                        "update_order_queue",String.valueOf(assembleId) , message -> {
                            message.getMessageProperties().setHeader("x-delay",5000);
                            return message;
                        });
                log.info("得到锁并且完成拼单操作");
            }
            AssembleDetailVo assembleDetailVo=new AssembleDetailVo();
            BeanUtils.copyProperties(assemble,assembleDetailVo);
            List<AssembleItem> assembleItemList=Lists.newArrayList();
            assembleDetailVo.setAssembleItemList(assembleItemList);
            assembleDetailVo.getAssembleItemList().addAll( assembleMapper.selectAssembleDetailInfoById(assembleId).getAssembleItems());
            return assembleDetailVo;
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            log.info("释放锁");
            if(locked){
                lock.unlock();
            }
        }
        return null;
    }
 
Example 12
Source File: PurchaseOrderServiceImpl.java    From ChengFeng1.5 with MIT License 4 votes vote down vote up
@Transactional
@Override
public PurchaseOrderVo placeSeparateOrder(Integer skuId, Integer count, Integer shippingId) {
    checkSpellArguments(skuId,count);
    //使用分布式锁
    Config config = new Config();
    config.useSingleServer()
            .setAddress(RedisConstant.Redisson.REDIS_ADDRESS);
    RedissonClient redisson = Redisson.create(config);
    RLock lock = redisson.getLock(RedisConstant.Redisson.LOCK_SPELL_ORDER);
    boolean locked = false;
    PurchaseProductSku productSku = productSkuMapper.selectAllByPrimaryKey(skuId);
    PurchaseCategory category=purchaseCategoryMapper.selectByPrimaryKey(productSku.getPurchaseProduct().getCategoryId());
    try{
        User user = AuthenticationInfoUtil.getUser(userMapper,memcachedClient);
        log.info("尝试获取下单锁");
        locked = lock.tryLock(10,TimeUnit.SECONDS);
        log.info("获取锁的状态:{}",locked);
        if(locked) {

                Long orderNo=Long.parseLong(stringRedisTemplate.opsForValue().increment(RedisConstant.COUNTER_ORDER).toString());
                PurchaseOrderItem purchaseOrderItem=new PurchaseOrderItem();
                purchaseOrderItem.setCurrentUnitPrice(productSku.getPrice());
                purchaseOrderItem.setOrderNo(orderNo);
                purchaseOrderItem.setQuantity(count);
                purchaseOrderItem.setNickname(user.getNickname());
                purchaseOrderItem.setProductName(String.join(" ",productSku.getPurchaseProduct().getName(),productSku.getAttributeName()));
                purchaseOrderItem.setProductId(skuId);
                purchaseOrderItem.setProductImage(MoreObjects.firstNonNull(productSku.getPurchaseProduct().getMainImage(),""));
                purchaseOrderItem.setTotalPrice(productSku.getPrice().multiply(new BigDecimal(count)));
                orderItemMapper.insert(purchaseOrderItem);
                PurchaseOrder purchaseOrder=new PurchaseOrder();
                purchaseOrder.setCloseTime(null);
                purchaseOrder.setEndTime(null);
                purchaseOrder.setSendTime(new Date());
                purchaseOrder.setOrderNo(orderNo);
                purchaseOrder.setPayment(productSku.getPrice().multiply(new BigDecimal(count)));
                purchaseOrder.setPaymentType(0);//非拼单
                purchaseOrder.setPaymentTime(new Date());
                purchaseOrder.setShippingId(shippingId);
                purchaseOrder.setStatus(OrderStatus.UNRECEIVED.getCode());
                purchaseOrder.setAvatar(user.getAvatar());
                purchaseOrder.setNickname(user.getNickname());
                purchaseOrderMapper.insert(purchaseOrder);
                //更新库存
                Integer stock = Integer.parseInt(stringRedisTemplate.opsForHash().get(RedisConstant.PRODUCT_STOCKS,
                        RedisConstant.PRODUCT_PREFIX_SKU + skuId).toString());
                stringRedisTemplate.opsForHash().put(RedisConstant.PRODUCT_STOCKS,
                        RedisConstant.PRODUCT_PREFIX_SKU + skuId,String.valueOf(stock-count));
                PurchaseOrderVo purchaseOrderVo=new PurchaseOrderVo();
                PurchaseOrderItemVo orderItemVo=new PurchaseOrderItemVo();
                BeanUtils.copyProperties(purchaseOrderItem,orderItemVo);
                BeanUtils.copyProperties(purchaseOrder,purchaseOrderVo);
                List<PurchaseOrderItemVo> orderItemVos=Lists.newArrayList();
                purchaseOrderVo.setOrderItems(orderItemVos);
                purchaseOrderVo.getOrderItems().add(orderItemVo);
                PurchaseShipping shipping=purchaseShippingMapper.selectByPrimaryKey(shippingId);


            Optional<PurchaseProduct> optional = productRepository.findById(productSku.getPurchaseProduct().getId());
            if (optional.isPresent()){
                PurchaseProduct purchaseProduct = optional.get();
                productSku.setPurchaseProduct(purchaseProduct);
            }

            ShippingVo shippingVo=new ShippingVo();
            if (shipping != null) {
                BeanUtils.copyProperties(shipping,shippingVo);
            }
            purchaseOrderVo.setShippingVo(shippingVo);
                return purchaseOrderVo;
            }
    }catch (Exception e) {
        log.error("下单失败");
    }finally {
        PurchaseInfoDto purchaseInfoDto = AssemblyDataUtil.assemblyPurchaseInfo(productSku, count, category,stringRedisTemplate);

        kafkaTemplate.send("topic-demo",purchaseInfoDto);
        log.info("释放锁");
        if(locked){
            lock.unlock();
        }
    }
    return null;
}
 
Example 13
Source File: RequestLimitInterceptor.java    From shopify-api-java-wrapper with Apache License 2.0 4 votes vote down vote up
@Override
public void apply(RequestTemplate template)
{
    Boolean tryGetCredit = true;

    RedissonClient redisson = _shopifyRedissonManager.getRedissonClient();

    while (tryGetCredit)
    {
        // Lock per shopify store. The lock is distributed, so it will work for multiple threads and applications.
        RLock lock = redisson.getLock(_shopifyRedissonManager.getMyShopifyUrl());

        RAtomicLong isDefaultRemainingCreditsValueSet = redisson.getAtomicLong(_shopifyRedissonManager.getIsDefaultRemainingCreditsValueSetKey());

        RAtomicLong remainingCreditsAtomic = redisson.getAtomicLong(_shopifyRedissonManager.getRemainingCreditsKey());

        if(isDefaultRemainingCreditsValueSet.get() == 0)
        {
            remainingCreditsAtomic.set(_shopifyRedissonManager.getCreditLimit());
            isDefaultRemainingCreditsValueSet.set(1);
        }

        RAtomicLong lastRequestTimeAtomic = redisson.getAtomicLong(_shopifyRedissonManager.getLastRequestTimeKey());
        Long remainingCredits = remainingCreditsAtomic.get();

        if(remainingCredits > 0)
        {
            // These values are set here, because a request can be made while the current request is still in progress.
            // We set the actual values inside the decoder (when the request is complete), but if we don't set them here
            // as well a raised condition can occur.
            remainingCreditsAtomic.set(remainingCredits - 1);
            lastRequestTimeAtomic.set(System.currentTimeMillis());

            tryGetCredit = false;
            lock.unlock();
        }
        else
        {
            // Check if there were enough time since the last request time.
            // If the latest request's remaining calls were 0 and no calls were made after that, the remaining credits
            // will not be updated. This is why the last request time is used as well.
            long availableCalls = (long)Math.floor((System.currentTimeMillis() - lastRequestTimeAtomic.get())/500);

            if(availableCalls > 0)
            {
                remainingCreditsAtomic.set(availableCalls - 1);
                lastRequestTimeAtomic.set(System.currentTimeMillis());

                tryGetCredit = false;
                lock.unlock();
            }
            else
            {
                lock.unlock();

                try
                {
                    Thread.sleep(1000);
                }
                catch (InterruptedException e)
                {
                    System.out.println("Error while waiting for available Shopify call credit. " + e.getMessage());
                }
            }
        }
    }
}
 
Example 14
Source File: RedissonRedLockTest.java    From redisson with Apache License 2.0 4 votes vote down vote up
private void testLockLeasetime(final long leaseTime, final TimeUnit unit) throws IOException, InterruptedException {
    RedisProcess redis1 = redisTestMultilockInstance();
    RedisProcess redis2 = redisTestMultilockInstance();
    
    RedissonClient client1 = createClient(redis1.getRedisServerAddressAndPort());
    RedissonClient client2 = createClient(redis2.getRedisServerAddressAndPort());
    
    RLock lock1 = client1.getLock("lock1");
    RLock lock2 = client1.getLock("lock2");
    RLock lock3 = client2.getLock("lock3");
    RLock lock4 = client2.getLock("lock4");
    RLock lock5 = client2.getLock("lock5");
    RLock lock6 = client2.getLock("lock6");
    RLock lock7 = client2.getLock("lock7");


    RedissonRedLock lock = new RedissonRedLock(lock1, lock2, lock3, lock4, lock5, lock6, lock7);
    
    ExecutorService executor = Executors.newFixedThreadPool(10);
    AtomicInteger counter = new AtomicInteger();
    for (int i = 0; i < 10; i++) {
        executor.submit(() -> {
            for (int j = 0; j < 5; j++) {
                try {
                    lock.lock(leaseTime, unit);
                    int nextValue = counter.get() + 1;
                    Thread.sleep(1000);
                    counter.set(nextValue);
                    lock.unlock();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
    }
    
    executor.shutdown();
    assertThat(executor.awaitTermination(2, TimeUnit.MINUTES)).isTrue();
    assertThat(counter.get()).isEqualTo(50);
    
    client1.shutdown();
    client2.shutdown();
    
    assertThat(redis1.stop()).isEqualTo(0);
    assertThat(redis2.stop()).isEqualTo(0);
}
 
Example 15
Source File: RedissonRedLockTest.java    From redisson with Apache License 2.0 4 votes vote down vote up
@Test
public void testTryLockLeasetime() throws IOException, InterruptedException {
    RedisProcess redis1 = redisTestMultilockInstance();
    RedisProcess redis2 = redisTestMultilockInstance();
    
    RedissonClient client1 = createClient(redis1.getRedisServerAddressAndPort());
    RedissonClient client2 = createClient(redis2.getRedisServerAddressAndPort());
    
    RLock lock1 = client1.getLock("lock1");
    RLock lock2 = client1.getLock("lock2");
    RLock lock3 = client2.getLock("lock3");

    RedissonRedLock lock = new RedissonRedLock(lock1, lock2, lock3);
    
    ExecutorService executor = Executors.newFixedThreadPool(10);
    AtomicInteger counter = new AtomicInteger();
    for (int i = 0; i < 10; i++) {
        executor.submit(() -> {
            for (int j = 0; j < 5; j++) {
                try {
                    if (lock.tryLock(4, 2, TimeUnit.SECONDS)) {
                        int nextValue = counter.get() + 1;
                        Thread.sleep(1000);
                        counter.set(nextValue);
                        lock.unlock();
                    } else {
                        j--;
                    }
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
    }
    
    executor.shutdown();
    assertThat(executor.awaitTermination(2, TimeUnit.MINUTES)).isTrue();
    assertThat(counter.get()).isEqualTo(50);
    
    client1.shutdown();
    client2.shutdown();
    
    assertThat(redis1.stop()).isEqualTo(0);
    assertThat(redis2.stop()).isEqualTo(0);
}
 
Example 16
Source File: RedissionUtils.java    From Redis_Learning with Apache License 2.0 2 votes vote down vote up
/** 
 * ��ȡ�� 
 * @param redisson 
 * @param objectName 
 * @return 
 */  
public RLock getRLock(RedissonClient redisson,String objectName){  
    RLock rLock=redisson.getLock(objectName);  
    return rLock;  
}