Grails:使用新的多数据源进行分片?
我希望能够根据字段的值将一个对象放入多个分片之一。在里程碑 2.0 中,我看到了类似“
def zipCode = ZipCode.auditing.get(42)
zipCode.auditing.save()
但是我将如何动态选择数据源”的示例。我想要更多类似的东西
ZipCode.datasource(1).get(42) // where 1 is calculated based on some other value.
有什么办法吗?
I want to be able to put an object into one of several shards based on a value of a field. In milestone 2.0 I see examples like
def zipCode = ZipCode.auditing.get(42)
zipCode.auditing.save()
But how would I dynamically choose the data source. I want something more like
ZipCode.datasource(1).get(42) // where 1 is calculated based on some other value.
Is there anyway to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅使用数据源插件的 http://grails.org/plugin/sharding。 Grails 中新的多数据源支持是将 Datasources 插件移至核心的结果,因此更新插件或借用其代码并进行调整应该很简单。
See http://grails.org/plugin/sharding which uses the Datasources plugin. The new multiple-datasources support in Grails is the result of moving the Datasources plugin into core, so it should be straightforward to either update the plugin or borrow its code and adapt it.