Skip to content

这里有个问题 #2

@wingahi

Description

@wingahi
		if (isTimeExpired(currLockInfo.getExpires())) {
			// 锁超时了
			LockInfo oldLockInfo = LockInfo.fromString(jedis.getSet(lockKey, newLockInfoJson));
                            //,这里需要判断redis所内容是否为当前锁,要不然并发情况会被多个线程获得锁
                            //String newSetLockInfoJson = redisTemplate.opsForValue().get(lockKey);
			//if (oldLockInfo != null && isTimeExpired(oldLockInfo.getExpires()) && 
                            //newSetLockInfoJson.equals(newLockInfoJson)) {
			if (oldLockInfo != null && isTimeExpired(oldLockInfo.getExpires())) {
				// 成功获取到锁, 设置相关标识
				logger.debug("{} get lock(new), lockInfo: {}", Thread.currentThread().getName(), newLockInfoJson);
				locked = true;
				return true;
			}
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions