开发者

Grails: Use new Multiple Datasources for sharding?

开发者 https://www.devze.com 2023-03-28 18:26 出处:网络
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

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 c开发者_如何学JAVAalculated based on some other value.

Is there anyway to do that?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号