7.1 Methods for Connecting to True Cache

Applications can use True Cache in the several ways.

  • Two physical connections

    The application maintains two physical connections: one to the primary database and one to True Cache. Each connection has a database application service, and the application chooses which connection to use based on whether it's reading or writing. You can use this model with any existing client drivers and any programming language.

    The application sends queries that don't need to see the most current data to True Cache through a True Cache database application service. The application sends other queries and updates to the primary database through the primary database application service.

  • One logical connection (JDBC Thin driver)

    The application maintains one logical connection that uses the database application service for the primary database. The JDBC Thin driver (starting with Oracle AI Database 26ai) maintains physical connections to the primary database and True Cache. This model only works with Java applications.

    The application switches between the primary database and True Cache without having to specify an instance name. The application uses special calls to flag the logical connection as read-only or read-write. If it's read-only, the query is sent to True Cache. Otherwise, it's sent to the primary database.

    To enable the True Cache functionality for Java applications, set the value of the oracle.jdbc.useTrueCacheDriverConnection property to true. After you enable True Cache, the JDBC Thin driver uses the standard java.sql.Connection.setReadOnly(boolean) and java.sql.Connection.isReadOnly() methods to mark a connection as read-only. By default, the read-only mode is false for a connection.

  • Single Oracle Call Interface (OCI) session pool

    Starting with Oracle AI Database 26ai, Release Update 23.26.0, you can use a single OCI session pool to manage connections to both a primary database and True Cache.

    You initialize the pool with the service names for the primary database and True Cache. The application can either request a session from the primary database (default) or explicitly request a read-only session from True Cache. There's also an option to prefer True Cache, if available, and otherwise fall back to the primary database.

    To enable session pooling for True Cache, initialize the session pool in multiple service pool mode by specifying the mode OCI_SPC_TRUECACHE for OCISessionPoolCreate(). To get read-only sessions from True Cache, use OCISessionGet() with OCI_SESSGET_READ_ONLY mode. To fall back to the primary database if no True Cache session is available, use OCI_SESSGET_READ_PREFER mode. If the mode is not specified, the session gets the connection from the primary database instance by default.

    For details, see True Cache Session Pooling in Oracle Call Interface Developer's Guide.

See the following technical architecture diagram for details and examples:

True Cache Application