mirror of
https://github.com/Geniusay/ChopperBot.git
synced 2026-05-28 00:55:01 +08:00
FileCache更改
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user