FileCache更改

This commit is contained in:
userA
2023-04-25 21:26:11 +08:00
parent 57d0553c5d
commit eba9c32c8f
3 changed files with 101 additions and 41 deletions

View File

@@ -38,9 +38,6 @@ public class FileCacheTest {
FileCache fileCache = new FileCache(moduleSrcConfigFile);
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
manager.start();
for(int i=0;i<1;i++){
fileCache.append("sectionwork",Integer.toString(i));
}
Thread.sleep(500000);
}
@@ -52,20 +49,61 @@ public class FileCacheTest {
FileCacheManager manager = new FileCacheManager(List.of(fileCache));
manager.start();
System.out.println(fileCache.get("sectionwork", "src"));
//fileCache.append(1,"sectionwork","src","0");
System.out.println(fileCache.get("barrage","src"));
fileCache.append(1,"barrage","src");
}
@Test
public void TestAppend() 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<10;i++){
fileCache.append(i,"sectionwork","src","0");
}
//追加数组
for(int i=0;i<10;i++){
fileCache.append(i,"sectionwork","src","-1");
}
//追加类中的元素
for(int i=0;i<10;i++){
fileCache.append(i,"barrage","src");
}
Thread.sleep(500000);
}
@Test
public void TestWrite() 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<10;i++){
fileCache.writeKeys(i,"sectionwork","src","0");
}
//追加数组
for(int i=0;i<10;i++){
fileCache.writeKeys(i,"sectionwork","src","-1");
}
//更改类中的元素
for(int i=0;i<10;i++){
fileCache.writeKeys(i,"barrage","src");
}
Thread.sleep(500000);
}
@Test
public void TestJson(){
String a = "{username:'[1,2,3,4]',age:{'hello':'world'}}";
Object jsonObject = JSONObject.parse(a);
Student student = new Student("Genius",18,"qinghua","SC",List.of("1","2","3"),null);
String s = JSONObject.toJSONString("");
JSONObject jsonObject = JSONObject.parseObject(s);
jsonObject.put("hobby",List.of("1","2","3","4").toString());
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());
}
}