mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-04-05 17:37:53 +08:00
sa-token-solon-plugin: 升级 redisx 为 1.4.7(set 指令改为 setex),解决 dao 适配在并发下 getTimeout 值可能与 set 行为不同步的问题
This commit is contained in:
parent
dccf0433d6
commit
87b9c4a435
9
pom.xml
9
pom.xml
@ -22,10 +22,11 @@
|
||||
<module>sa-token-core</module>
|
||||
<module>sa-token-starter</module>
|
||||
<module>sa-token-plugin</module>
|
||||
<!-- <module>sa-token-test</module> -->
|
||||
<!-- <module>sa-token-demo/sa-token-demo-solon</module> -->
|
||||
<!-- <module>sa-token-demo/sa-token-demo-sso-server-solon</module> -->
|
||||
</modules>
|
||||
<module>sa-token-demo/sa-token-demo-sso-server-solon</module>
|
||||
<module>sa-token-demo/sa-token-demo-sso1-client-solon</module>
|
||||
<module>sa-token-demo/sa-token-demo-sso2-client-solon</module>
|
||||
<module>sa-token-demo/sa-token-demo-sso3-client-solon</module>
|
||||
</modules>
|
||||
|
||||
<!-- 开源协议 apache 2.0 -->
|
||||
<licenses>
|
||||
|
@ -41,13 +41,7 @@ public class SaTokenDaoOfRedisBase64 implements SaTokenDao {
|
||||
*/
|
||||
@Override
|
||||
public void set(String key, String value, long timeout) {
|
||||
if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) {
|
||||
return;
|
||||
}
|
||||
// 判断是否为永不过期
|
||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
redisBucket.store(key, value, (int) SaTokenDao.NEVER_EXPIRE);
|
||||
} else {
|
||||
if (timeout > 0 || timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
redisBucket.store(key, value, (int) timeout);
|
||||
}
|
||||
}
|
||||
@ -58,10 +52,6 @@ public class SaTokenDaoOfRedisBase64 implements SaTokenDao {
|
||||
@Override
|
||||
public void update(String key, String value) {
|
||||
long expire = getTimeout(key);
|
||||
// -2 = 无此键
|
||||
if (expire == SaTokenDao.NOT_VALUE_EXPIRE) {
|
||||
return;
|
||||
}
|
||||
this.set(key, value, expire);
|
||||
}
|
||||
|
||||
@ -86,18 +76,9 @@ public class SaTokenDaoOfRedisBase64 implements SaTokenDao {
|
||||
*/
|
||||
@Override
|
||||
public void updateTimeout(String key, long timeout) {
|
||||
// 判断是否想要设置为永久
|
||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
long expire = getTimeout(key);
|
||||
if (expire == SaTokenDao.NEVER_EXPIRE) {
|
||||
// 如果其已经被设置为永久,则不作任何处理
|
||||
} else {
|
||||
// 如果尚未被设置为永久,那么再次set一次
|
||||
this.set(key, this.get(key), timeout);
|
||||
}
|
||||
return;
|
||||
if (redisBucket.exists(key)) {
|
||||
redisBucket.delay(key, (int) timeout);
|
||||
}
|
||||
redisBucket.delay(key, (int) timeout);
|
||||
}
|
||||
|
||||
|
||||
@ -114,13 +95,7 @@ public class SaTokenDaoOfRedisBase64 implements SaTokenDao {
|
||||
*/
|
||||
@Override
|
||||
public void setObject(String key, Object object, long timeout) {
|
||||
if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) {
|
||||
return;
|
||||
}
|
||||
// 判断是否为永不过期
|
||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
redisBucket.storeAndSerialize(key, object);
|
||||
} else {
|
||||
if (timeout > 0 || timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
redisBucket.storeAndSerialize(key, object, (int) timeout);
|
||||
}
|
||||
}
|
||||
@ -131,10 +106,6 @@ public class SaTokenDaoOfRedisBase64 implements SaTokenDao {
|
||||
@Override
|
||||
public void updateObject(String key, Object object) {
|
||||
long expire = getObjectTimeout(key);
|
||||
// -2 = 无此键
|
||||
if (expire == SaTokenDao.NOT_VALUE_EXPIRE) {
|
||||
return;
|
||||
}
|
||||
this.setObject(key, object, expire);
|
||||
}
|
||||
|
||||
@ -159,18 +130,9 @@ public class SaTokenDaoOfRedisBase64 implements SaTokenDao {
|
||||
*/
|
||||
@Override
|
||||
public void updateObjectTimeout(String key, long timeout) {
|
||||
// 判断是否想要设置为永久
|
||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
long expire = getObjectTimeout(key);
|
||||
if (expire == SaTokenDao.NEVER_EXPIRE) {
|
||||
// 如果其已经被设置为永久,则不作任何处理
|
||||
} else {
|
||||
// 如果尚未被设置为永久,那么再次set一次
|
||||
this.setObject(key, this.getObject(key), timeout);
|
||||
}
|
||||
return;
|
||||
if (redisBucket.exists(key)) {
|
||||
redisBucket.delay(key, (int) timeout);
|
||||
}
|
||||
redisBucket.delay(key, (int) timeout);
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,13 +57,7 @@ public class SaTokenDaoOfRedisJson implements SaTokenDao {
|
||||
*/
|
||||
@Override
|
||||
public void set(String key, String value, long timeout) {
|
||||
if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) {
|
||||
return;
|
||||
}
|
||||
// 判断是否为永不过期
|
||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
redisBucket.store(key, value, (int) SaTokenDao.NEVER_EXPIRE);
|
||||
} else {
|
||||
if (timeout > 0 || timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
redisBucket.store(key, value, (int) timeout);
|
||||
}
|
||||
}
|
||||
@ -74,10 +68,6 @@ public class SaTokenDaoOfRedisJson implements SaTokenDao {
|
||||
@Override
|
||||
public void update(String key, String value) {
|
||||
long expire = getTimeout(key);
|
||||
// -2 = 无此键
|
||||
if (expire == SaTokenDao.NOT_VALUE_EXPIRE) {
|
||||
return;
|
||||
}
|
||||
this.set(key, value, expire);
|
||||
}
|
||||
|
||||
@ -102,18 +92,9 @@ public class SaTokenDaoOfRedisJson implements SaTokenDao {
|
||||
*/
|
||||
@Override
|
||||
public void updateTimeout(String key, long timeout) {
|
||||
// 判断是否想要设置为永久
|
||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
long expire = getTimeout(key);
|
||||
if (expire == SaTokenDao.NEVER_EXPIRE) {
|
||||
// 如果其已经被设置为永久,则不作任何处理
|
||||
} else {
|
||||
// 如果尚未被设置为永久,那么再次set一次
|
||||
this.set(key, this.get(key), timeout);
|
||||
}
|
||||
return;
|
||||
if (redisBucket.exists(key)) {
|
||||
redisBucket.delay(key, (int) timeout);
|
||||
}
|
||||
redisBucket.delay(key, (int) timeout);
|
||||
}
|
||||
|
||||
|
||||
@ -130,12 +111,10 @@ public class SaTokenDaoOfRedisJson implements SaTokenDao {
|
||||
*/
|
||||
@Override
|
||||
public void setObject(String key, Object object, long timeout) {
|
||||
if (timeout == 0 || timeout <= SaTokenDao.NOT_VALUE_EXPIRE) {
|
||||
return;
|
||||
if (timeout > 0 || timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
String value = ONode.serialize(object);
|
||||
set(key, value, timeout);
|
||||
}
|
||||
|
||||
String value = ONode.serialize(object);
|
||||
set(key, value, timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,10 +123,6 @@ public class SaTokenDaoOfRedisJson implements SaTokenDao {
|
||||
@Override
|
||||
public void updateObject(String key, Object object) {
|
||||
long expire = getObjectTimeout(key);
|
||||
// -2 = 无此键
|
||||
if (expire == SaTokenDao.NOT_VALUE_EXPIRE) {
|
||||
return;
|
||||
}
|
||||
this.setObject(key, object, expire);
|
||||
}
|
||||
|
||||
@ -172,18 +147,9 @@ public class SaTokenDaoOfRedisJson implements SaTokenDao {
|
||||
*/
|
||||
@Override
|
||||
public void updateObjectTimeout(String key, long timeout) {
|
||||
// 判断是否想要设置为永久
|
||||
if (timeout == SaTokenDao.NEVER_EXPIRE) {
|
||||
long expire = getObjectTimeout(key);
|
||||
if (expire == SaTokenDao.NEVER_EXPIRE) {
|
||||
// 如果其已经被设置为永久,则不作任何处理
|
||||
} else {
|
||||
// 如果尚未被设置为永久,那么再次set一次
|
||||
this.setObject(key, this.getObject(key), timeout);
|
||||
}
|
||||
return;
|
||||
if (redisBucket.exists(key)) {
|
||||
redisBucket.delay(key, (int) timeout);
|
||||
}
|
||||
redisBucket.delay(key, (int) timeout);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user