cnregion icon indicating copy to clipboard operation
cnregion copied to clipboard

能提供方法把db全部加载到redis

Open biancheng347 opened this issue 1 year ago • 10 comments

我们对db 有大量频发的查询

biancheng347 avatar Sep 25 '24 12:09 biancheng347

现在是直接加载到内存,比保存在 redis 要快许多。

caixw avatar Sep 25 '24 14:09 caixw

你的意思默认初始化 就是加载到应用内存中?如果这样的话,我就没有必要在redis 在搞缓存?

biancheng347 avatar Sep 25 '24 14:09 biancheng347

用 LoadFile 加载 data/regions.db 或是调用 data.Embed 可以将内容加载至内存。

caixw avatar Sep 25 '24 14:09 caixw

cnregion.LoadFile(path+"/regions.db", "-", 2023) 嗯,好的,如果这样的 我把redis缓存去掉

biancheng347 avatar Sep 25 '24 14:09 biancheng347

cnregion.LoadFile("./data/regions.db", "-", true, 2020),多了一个 bool 类型的参数,readme 中的示例没加上去。

caixw avatar Sep 25 '24 14:09 caixw

这个bool 是什么意思?

biancheng347 avatar Sep 25 '24 14:09 biancheng347

d, err := db.LoadFile(path, separator, true, version...)

默认不是添加上去吗?

biancheng347 avatar Sep 25 '24 14:09 biancheng347

你之前贴的代码里没有加,我就写了下。bool 表示加载的文件是否是经过压缩的。

caixw avatar Sep 25 '24 14:09 caixw

1.压缩是什么意思?2.现在知道村居委,能不能村居委下面的自然村/行政村 也有数据

biancheng347 avatar Sep 25 '24 14:09 biancheng347

  1. 表示加载的 regions.db 文件是否是经过压缩的;
  2. 自然村/行政村 正式名称应该也是 XX 村委会。 所有数据来自官方给出的数据。如果缺少数据,可能是在指定年份里,该村已经被合并了或是还未成立,可以加载不同年份的数据看看。

caixw avatar Sep 25 '24 14:09 caixw