Replies: 1 comment
-
|
这个思路是可以的,在 java client 中也有类似的实现 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
在 example 中,获取 kv 的代码如下:
这样获取到的
value可能为string/map[string]interface{}类型在实际的业务场景中,我们往往需要对
value再进行一次反序列化,将其解码为业务领域的一个结构体。因此我在想能不能将后面这个步骤直接整合进 agollo 库里,这应该是一个通用需求。
整合后的使用方式如下:
还可以进一步做成支持泛型的方式。但 golang 目前的泛型不支持方法,只能做成全局函数;且需要升级 go.mod 中的 golang 版本至 1.18:
这个 idea 如何?如果觉得 ok 的话,我可以负责开发。目前的 kv 保存在
cache.defaultCache里,只需在cache中增加一个二级缓存,保存解析后的结构体,应该就可以实现Beta Was this translation helpful? Give feedback.
All reactions