Sitemap

True Cache — Oracle Database 23ai

5 min readMay 20, 2024

--

In the world of computers, speed matters. Whether you’re browsing the web or managing data in a database, faster is almost always better. That’s where caching comes in — a smart way to make things quicker and smoother. Let’s take a closer look at caching, its different types, and a game-changing innovation from Oracle called True Cache.

Understanding Caching: Making Things Faster

Cache, in the context of computing, is a component that stores data so that future requests for that data can be served faster. It acts as a temporary storage area where frequently accessed or recently used data is kept. Caching improves performance by reducing the need to access the original data source every time it is requested.

Exploring Different Types of Caching

Caching comes in different flavors, each serving a specific purpose:

Caching

Client-Side Caching: Your browser keeps copies of web pages and resources locally to speed up browsing.

Server-Side Caching: Servers store frequently accessed data to reduce load and improve response times.

Database-Side Caching: Databases cache query results to speed up data retrieval and processing.

Proxy Caching: Intermediary servers cache content to reduce bandwidth usage and improve delivery speed.

Content Caching: Storing web content like images and pages to speed up access and reduce server load.

True Cache by Oracle: A Game-Changer in Database Performance

Now, let’s talk about True Cache. It’s a new tool from Oracle that makes database caching smarter and faster:

With True Cache, developers can effortlessly deploy a diskless instance to their mid-tier infrastructure and leave the management to Oracle. Leveraging the power of “Active Dataguard” technology, Oracle Database 23ai ensures the consistency of the cache with the latest updates from the primary instance, retrieving data when needed (in case of cache miss).

Press enter or click to view image in full size
Oracle Database 23ai
  • In-Memory Caching: True Cache stores data in memory, making database queries lightning fast.
  • Read-Only Replication: It creates a copy of the main database, so you get the latest data without slowing things down.
  • Committed Data Retrieval: True Cache only fetches data that’s been committed, ensuring accuracy and reliability.
  • Supports All Data Types: From numbers to graphs, True Cache handles all kinds of data, making it versatile and flexible.
  • Advanced Features: With tricks like parallel queries and compression, True Cache squeezes every drop of performance out of your database.
True Cache — Oracle Database 23ai

Conclusion: Boosting Performance with True Cache

Get Baig Mohammed’s stories in your inbox

Join Medium for free to get updates from this writer.

In a world where speed is king, caching is a lifesaver. And with innovations like True Cache, Oracle is taking database performance to the next level. By making data access faster, more reliable, and more efficient, True Cache helps businesses stay ahead of the competition and deliver top-notch experiences to their users. So, if you’re looking to supercharge your database, True Cache might just be the secret weapon you need.

At a high level, here’s how Oracle True Cache works.

. An application decides whether to query data from True Cache or the primary database. For details on how this works, see Application Usage Models.

. True Cache satisfies queries by using data that’s cached in its memory. When the data isn’t in the cache, True Cache fetches the data from the primary database.

. True Cache is empty when it starts up, so it reads large chunks of data to populate the cache. After a block is cached, it’s updated automatically through redo apply from the primary database. This is similar to the update mechanism used in Oracle Active Data Guard.

. A query to True Cache returns only committed data, and the data is always consistent. • Like all caches, the True Cache data might not be the most current data as it exists in the primary database.

. If multiple True Caches exist and serve the same database application service, the listener automatically distributes and load balances sessions to each cache.

Follow these steps to set up a True Cache environment manually if you’re not using the Oracle Database Configuration Assistant (Oracle DBCA).

. Prerequisites Before configuring True Cache, complete the following steps.

. Creating True Cache Follow these steps to create True Cache.

. Configuring Database Application Services for True Cache To use True Cache with the JDBC Thin driver, for each primary database application service that you want to cache, create a corresponding True Cache database application service.

Sample Java Code Using the JDBC Thin Driver The JDBC method:

Changes the isReadOnly connection parameter to TRUE to automatically switch the connection to True Cache and verify that it’s connected to it.

public void test1() throws SQLException {
show("Basic test to connect to primary and True Cache");
try {
show("Get Connection from True Cache instance using primary db and
properties");
OracleDataSource ods1 = new OracleDataSource();
show("URL = " + url_primary);
ods1.setURL(url_primary);
ods1.setUser(user);
ods1.setPassword(password);
ods1.setConnectionProperty("oracle.jdbc.useTrueCacheDriverConnection",
"true");
Connection conn1 = ods1.getConnection();
show("isReadonly " + conn1.isReadOnly());
verifyConnection(conn1); // This is connected to Primary

conn1.setReadOnly(true);
show("isReadonly " + conn1.isReadOnly());
verifyConnection(conn1); // This is connected to True Cache
conn1.close();
} catch (SQLException sqex) {
show("test1 -- failed" + sqex.getMessage()+":"+sqex.getCause());
sqex.printStackTrace();
}
show("The end");
}

References

Introduction True Cache

True Cache User Guide to config and test from Java code

Introducing Oracle True Cache : In-memory, consistent, and automatically managed SQL cache (Oracle Database 23ai) by Pankaj Chandiramani and Bill Lee

#Caching #DatabaseCaching #TrueCache #23ai #oci #OracleACE

--

--