Skip to content

Commit

Permalink
Merge pull request #3406 from KouShenhai/dev
Browse files Browse the repository at this point in the history
style: 移除异步操作
  • Loading branch information
KouShenhai authored Jan 23, 2025
2 parents cc9f894 + 71bfd28 commit 2a79962
Showing 1 changed file with 0 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@

import com.baomidou.mybatisplus.extension.parser.cache.AbstractCaffeineJsqlParseCache;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import org.laokou.common.i18n.utils.ObjectUtil;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.function.Consumer;

/**
* jsqlparser 缓存 fury 序列化 Caffeine 缓存实现.
Expand All @@ -37,32 +31,6 @@ public FurySerialCaffeineJsqlParseCache(Cache<String, byte[]> cache) {
super(cache);
}

public FurySerialCaffeineJsqlParseCache(Consumer<Caffeine<Object, Object>> consumer) {
super(consumer);
}

public FurySerialCaffeineJsqlParseCache(Cache<String, byte[]> cache, Executor executor, boolean async) {
super(cache);
// 开启异步
super.async = async;
super.executor = executor;
}

@Override
protected void put(String sql, Object value) {
if (async) {
if (ObjectUtil.isNotNull(executor)) {
executor.execute(() -> cache.put(sql, serialize(value)));
}
else {
CompletableFuture.runAsync(() -> cache.put(sql, serialize(value)));
}
}
else {
cache.put(sql, serialize(value));
}
}

@Override
public byte[] serialize(Object obj) {
return FuryFactory.getFuryFactory().serialize(obj);
Expand Down

0 comments on commit 2a79962

Please sign in to comment.