一次性加载所有表
()
| 8 | |
| 9 | // 一次性加载所有表 |
| 10 | func LoadAllTable() { |
| 11 | |
| 12 | var Tab = NewTable() |
| 13 | |
| 14 | // 表加载前清除之前的手动索引和表关联数据 |
| 15 | Tab.RegisterPreEntry(func(tab *Table) error { |
| 16 | fmt.Println("tab pre load clear") |
| 17 | return nil |
| 18 | }) |
| 19 | |
| 20 | // 表加载和构建索引后,需要手动处理数据的回调 |
| 21 | Tab.RegisterPostEntry(func(tab *Table) error { |
| 22 | fmt.Println("tab post load done") |
| 23 | fmt.Printf("%+v\n", tab.ExampleDataByID[200]) |
| 24 | |
| 25 | fmt.Println("KV: ", tab.GetKeyValue_ExampleKV().ServerIP) |
| 26 | return nil |
| 27 | }) |
| 28 | |
| 29 | err := tabtoy.LoadFromFile(Tab, "../json/table_gen.json") |
| 30 | if err != nil { |
| 31 | fmt.Println(err) |
| 32 | os.Exit(1) |
| 33 | } |
| 34 | |
| 35 | fmt.Println("") |
| 36 | } |
| 37 | |
| 38 | // 按指定表加载 |
| 39 | func LoadSpecifiedTable() { |
no test coverage detected