Class Home<T>


  • public class Home<T>
    extends Object
    Base implementation of a data access object.

    If using a jdbc driver with Statement caching (e.g. PG, Oracle, MySQL) or for fine-grain control over memory use, consider calling setStatementCacheEnabled(false) and closing Connections and their Statements with try-resource or finally. If using HikariCP, set these properties:

    • minimumIdle: set to count of services concurrently using this Home X 2.
    • maximumPoolSize: set at least 2X larger than minIdleCount or db process count.
    • idleTimeout: 600000 (millisec), max time before HikariCP evicts idle connections.

    Hikari docs: It is imperative the app configures driver-level TCP socket timeout. For Postgresql (PG), set socketTimeout to greater of 2-3X the longest query or 30 sec.

    PG docs: If reading from the server takes longer than this value, the connection is closed. An easy way configure PG socketTimeout when using HikariCP is to use its idleTimeout (in seconds):

    hikariConf.addDataSourceProperty("socketTimeout", idleTimeout/1000)

    Hikari recovery notes (after network outage or RDS failover): Recovery time should take the greater of idleTimeout and socket timeout on the driver. During recovery, nobody should call getConnection allowing the pool to evict idle connections. A longer time is more tolerant of long-running queries but also prolongs recovery. See Hikari rapid recovery Hikari rapid recovery 2

    See Also:
    setStatementCacheEnabled(boolean)