FileCache更改

This commit is contained in:
userA
2023-04-25 19:38:47 +08:00
parent 8b0cef608d
commit e6214ee709
2 changed files with 89 additions and 25 deletions

View File

@@ -1,5 +1,6 @@
package org.example.cache;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONPObject;
import org.example.bean.ModuleSrcConfigFile;
@@ -12,6 +13,8 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static org.apache.logging.log4j.message.MapMessage.MapFormat.JSON;
/**
* @author Genius
* @date 2023/04/24 03:30
@@ -33,13 +36,36 @@ public class FileCacheTest {
public void TestFileCacheManager() throws FileCacheException, InterruptedException {
ModuleSrcConfigFile moduleSrcConfigFile = new ModuleSrcConfigFile();
FileCache fileCache = new FileCache(moduleSrcConfigFile);
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
manager.start();
for(int i=0;i<1000;i++){
for(int i=0;i<1;i++){
fileCache.append("sectionwork",Integer.toString(i));
}
Thread.sleep(500000);
}
@Test
public void TestGet() throws FileCacheException, InterruptedException {
ModuleSrcConfigFile moduleSrcConfigFile = new ModuleSrcConfigFile();
FileCache fileCache = new FileCache(moduleSrcConfigFile);
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
manager.start();
System.out.println(fileCache.get("sectionwork", "src"));
//fileCache.append(1,"sectionwork","src","0");
}
@Test
public void TestJson(){
String a = "{username:'[1,2,3,4]',age:{'hello':'world'}}";
Object jsonObject = JSONObject.parse(a);
System.out.println(jsonObject);
System.out.println(jsonObject.getClass());
jsonObject = JSONArray.parse( ((JSONObject) jsonObject).get("username").toString() );
System.out.println(jsonObject);
System.out.println(jsonObject.getClass());
}
}