Skip to content

hellojavaer/ddal

Repository files navigation

DDAL

Build Status GitHub release

DDAL(Distributed Data Access Layer) is a simple solution to access database shard.

design

License

DDAL is dual licensed under LGPL V2.1 and Apache Software License, Version 2.0.

Useage

  • add the following dependency in your pom.xml
<dependency> <groupId>org.hellojavaer.ddal</groupId> <artifactId>ddal-datasource</artifactId> <version>1.0.0.M6</version> </dependency>
  • use DefaultDDALDataSource to proxy the orginal dataSource
<bean name="dataSource" class="org.hellojavaer.ddal.datasource.DefaultDDALDataSource"> <constructor-arg index="0" value="jdbc:ddal:thick:classpath:/datasource.xml"/> <!-- <constructor-arg index="0" value="jdbc:ddal:thick:http://{host}:{port}/{appName}"/> --> </bean> 

Download

http://repo1.maven.org/maven2/org/hellojavaer/ddal/

Documentation

Extensions in the latest version 1.0.0.M6

  • implement DefaultDDALDataSource in ddal-datasource module
<bean name="dataSource" class="org.hellojavaer.ddal.datasource.DefaultDDALDataSource"> <constructor-arg index="0" value="jdbc:ddal:thick:classpath:/datasource.xml"/> </bean> 
  • implement DivideShardRouteRule for range route

Extensions in version 1.0.0.M5

  • optimize route rule expression parser
// older SpelShardRouteRule rule = new SpelShardRouteRule(); rule.setScRouteRule("{#scName}_{#format('%02d', #sdValue % 4)}"); rule.setTbRouteRule("{#tbName}_{#format('%04d', #sdValue % 8)}"); // newer SpelShardRouteRule rule = new SpelShardRouteRule(); rule.setScRouteRule("{scName}_{format('%02d', sdValue % 4)}"); rule.setTbRouteRule("{tbName}_{format('%04d', sdValue % 8)}"); 
  • optimize range expression parser
"1,2,3" => 1,2,3 "[1..3]" => 1,2,3 "['A'..'C','X']" => A,B,C,X "[0..1][0..1]" => 00,01,10,11 "Hi![' Allen',' Bob']" => Hi! Allen,Hi! Bob 

About

DDAL(Distributed Data Access Layer) is a simple solution to access database shard.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages