Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,23 @@ default DataSourceBuilder leakTimeMinutes(int leakTimeMinutes) {
/**
* Set the size of the PreparedStatement cache (per connection).
* <p>
* Defaults to 100.
* Defaults to 300.
*/
default DataSourceBuilder pstmtCacheSize(int pstmtCacheSize) {
return setPstmtCacheSize(pstmtCacheSize);
}

/**
* @deprecated - migrate to {@link #pstmtCacheSize(int)}.
* Set the size of the PreparedStatement cache (per connection).
* <p>
* Defaults to 300.
*/
default DataSourceBuilder preparedStatementCacheSize(int pstmtCacheSize) {
return setPstmtCacheSize(pstmtCacheSize);
}

/**
* @deprecated - migrate to {@link #preparedStatementCacheSize(int)}.
*/
@Deprecated
DataSourceBuilder setPstmtCacheSize(int pstmtCacheSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class DataSourceConfig implements DataSourceBuilder.Settings {
private int maxInactiveTimeSecs = 300;
private int maxAgeMinutes = 0;
private int trimPoolFreqSecs = 59;
private int pstmtCacheSize = 100;
private int pstmtCacheSize = 300;
private int cstmtCacheSize = 20;
private int waitTimeoutMillis = 1000;
private String poolListener;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,39 @@ public void from_noPrefix() throws IOException {
assertConfigValues(builder2.settings());
}

@Test
void pstmtCacheSize_default_expect_300() {
DataSourceConfig config = new DataSourceConfig();
assertThat(config.getPstmtCacheSize()).isEqualTo(300);
}

@Test
void pstmtCacheSize_explicit_setValue() {
DataSourceConfig config = new DataSourceConfig();
config.setPstmtCacheSize(500);
assertThat(config.getPstmtCacheSize()).isEqualTo(500);
}

@Test
void pstmtCacheSize_builder_method() {
var builder = DataSourceBuilder.create()
.pstmtCacheSize(250);
assertThat(builder.settings().getPstmtCacheSize()).isEqualTo(250);
}

@Test
void preparedStatementCacheSize_builder_method() {
var builder = DataSourceBuilder.create()
.preparedStatementCacheSize(400);
assertThat(builder.settings().getPstmtCacheSize()).isEqualTo(400);
}

@Test
void preparedStatementCacheSize_builder_default() {
var builder = DataSourceBuilder.create();
assertThat(builder.settings().getPstmtCacheSize()).isEqualTo(300);
}

private static void assertConfigValues(DataSourceBuilder.Settings config) {
assertThat(config.getReadOnlyUrl()).isEqualTo("myReadOnlyUrl");
assertThat(config.getUrl()).isEqualTo("myUrl");
Expand Down
Loading