Flipper.sort兼容多余的空格

This commit is contained in:
redkale
2024-08-15 17:07:27 +08:00
parent c520910d5c
commit dd0debd51e
4 changed files with 11 additions and 10 deletions

View File

@@ -42,7 +42,7 @@
//实时修改远程缓存的key值 //实时修改远程缓存的key值
public void updateName(String code, Map<String, Long> map) { public void updateName(String code, Map<String, Long> map) {
cachedManager.remoteSetString(code + "_" + map.get("id"), Duration.ofMillis(60)); cachedManager.remoteSetString(code + "_" + map.get("id"), code + "-" + map, Duration.ofMillis(60));
} }
@Cached(key = "#{code}_#{map.id}", remoteExpire = "60", timeUnit = TimeUnit.MILLISECONDS) @Cached(key = "#{code}_#{map.id}", remoteExpire = "60", timeUnit = TimeUnit.MILLISECONDS)
@@ -104,7 +104,7 @@
//第一个缓存器实时修改远程缓存的key值 //第一个缓存器实时修改远程缓存的key值
public void updateName(String code, Map<String, Long> map) { public void updateName(String code, Map<String, Long> map) {
cachedManager.remoteSetString(code + "_" + map.get("id"), Duration.ofMillis(60)); cachedManager.remoteSetString(code + "_" + map.get("id"), code + "-" + map, Duration.ofMillis(60));
} }
//使用第一个缓存器 //使用第一个缓存器

View File

@@ -253,7 +253,7 @@ public abstract class AbstractDataSqlSource extends AbstractDataSource
if (sort.indexOf(';') >= 0 || sort.indexOf('\n') >= 0) { if (sort.indexOf(';') >= 0 || sort.indexOf('\n') >= 0) {
return ""; return "";
} }
return sortOrderbySqls.computeIfAbsent(sort, s -> { return sortOrderbySqls.computeIfAbsent(sort.trim(), s -> {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append(" ORDER BY "); sb.append(" ORDER BY ");
if (info.getBuilder().isNoAlias()) { if (info.getBuilder().isNoAlias()) {
@@ -261,6 +261,7 @@ public abstract class AbstractDataSqlSource extends AbstractDataSource
} else { } else {
boolean flag = false; boolean flag = false;
for (String item : s.split(",")) { for (String item : s.split(",")) {
item = item.trim();
if (item.isEmpty()) { if (item.isEmpty()) {
continue; continue;
} }

View File

@@ -23,11 +23,11 @@ import org.redkale.util.RedkaleException;
public class CachedInstance implements Service { public class CachedInstance implements Service {
@Resource @Resource
private CachedManager cacheManager; private CachedManager cachedManager;
// 修改远程缓存的key值 // 修改远程缓存的key值
public void updateName(String code, Map<String, Long> map) { public void updateName(String code, Map<String, Long> map) {
cacheManager.remoteSetString(code, code + "_" + map.get("id"), Duration.ofMillis(60)); cachedManager.remoteSetString(code + "_" + map.get("id"), code + "-" + map, Duration.ofMillis(60));
} }
@Cached(key = "#{code}_#{map.id}", remoteExpire = "60", timeUnit = TimeUnit.MILLISECONDS) @Cached(key = "#{code}_#{map.id}", remoteExpire = "60", timeUnit = TimeUnit.MILLISECONDS)
@@ -41,7 +41,7 @@ public class CachedInstance implements Service {
} }
public void updateName(String val) { public void updateName(String val) {
cacheManager.bothSet("name_2", String.class, val, Duration.ofSeconds(31), Duration.ofSeconds(60)); cachedManager.bothSet("name_2", String.class, val, Duration.ofSeconds(31), Duration.ofSeconds(60));
} }
@Cached(key = "name_2", localExpire = "31", remoteExpire = "60") @Cached(key = "name_2", localExpire = "31", remoteExpire = "60")
@@ -86,8 +86,8 @@ public class CachedInstance implements Service {
return CompletableFuture.completedFuture(null); return CompletableFuture.completedFuture(null);
} }
public CachedManager getCacheManager() { public CachedManager getCachedManager() {
return cacheManager; return cachedManager;
} }
public static class ParamBean { public static class ParamBean {

View File

@@ -80,8 +80,8 @@ public class CachedInstanceTest {
Assertions.assertEquals("haha", instance.getName2()); Assertions.assertEquals("haha", instance.getName2());
Assertions.assertEquals("haha", instance2.getName2()); Assertions.assertEquals("haha", instance2.getName2());
System.out.println("准备设置 updateName"); System.out.println("准备设置 updateName");
System.out.println("instance1.manager = " + instance.getCacheManager()); System.out.println("instance1.manager = " + instance.getCachedManager());
System.out.println("instance2.manager = " + instance2.getCacheManager()); System.out.println("instance2.manager = " + instance2.getCachedManager());
manager.updateBroadcastable(false); manager.updateBroadcastable(false);
instance.updateName("gege"); instance.updateName("gege");
Assertions.assertEquals("gege", instance.getName2()); Assertions.assertEquals("gege", instance.getName2());