What is Caching?
An independent cache can be added in front of a centralized data source (in our case, an Oracle database).
-
You can store copies of data derived from a centralized data source into one or more independent caches, which can be located closer to where data consumption occurs. This improves data access latency when used on read-only data that is accessed frequently. Lower latency means that there is a minimal delay in the transporting of data over a network connection resulting in smaller overall delay times.
-
An independent cache uses high-speed RAM for temporarily storing subsets of data. Future requests for that same data are served up faster than is possible by accessing the data from a centralized data source. The data on a centralized data source is typically stored on disk, which is also impacted by high rates of access.
-
You can store cached data for long periods of time or just temporarily.
-
You can keep the amount of data on the independent cache as small as possible while the data is still relevant to what is needed.
Since the data stored in the independent cache are copies of the data on the centralized data source, there are mechanisms to ensure that the cached data remains synchronized with the centralized data source.
There are two ways to use an independent cache:
-
As a read-only cache: Data is modified only on the centralized data source and these changes are propagated from the Oracle database to the independent cache as specified.
-
As a read-write cache: Data can be modified on either the independent cache or on the centralized data source. The data is propagated to either the independent cache or to the centralized data source as specified.
The specific actions for read-only and read-write operations within the independent cache are:
Actions for caching | The specific actions for read-only operations within the independent cache | The specific actions for read-write operations within the independent cache |
---|---|---|
What can be changed? |
Data can be changed at any time on the centralized data source. Data is not changed on the independent cache. |
Data can be changed at any time on the independent cache. While it is possible, data should not be changed on the centralized data source. |
How is the data in the independent cache and the centralized data source synchronized? |
Any changes made to the data on the centralized data source are propagated up from the centralized data source to the independent cache. |
Any changes made to the data on the independent cache can be manually or dynamically flushed down to the centralized data source. |
You use SQL statements to define what data is to be cached and how changes are propagated.
-
Read-Only operations use the
SELECT
SQL statement. For example:SELECT * FROM sales.customers; < 342, West, Jane Stone > < 663, East, Pat Reed > 2 rows found.
-
Read-Write operations use
SELECT
,INSERT
,UPDATE
, and/orDELETE
SQL statements. For example:INSERT INTO customers VALUES (342, "West", "Jane Stone"); 1 row created. DELETE FROM customers WHERE cust_num=122; I row deleted. UPDATE customers SET region="East" WHERE cust_num=663; 1 row updated.