Efficient caching is a cornerstone of high-performance applications. However, ensuring critical data remains in cache without manual intervention can be challenging. Oracle True Cache, with its KEEP pool, addresses this need seamlessly.
What makes Oracle True Cache unique?
A quick refresher for the readers who may be new to True Cache – Oracle True Cache is an in-memory, consistent, and automatically managed cache for Oracle Database. True Cache is a SQL cache as well as key-value (object or JSON) cache for the database. It caches all Oracle database objects and types. True Cache is a fully functional, read-only replica of the primary database, except that it’s mostly diskless. One of the most awesome features of True Cache is that it is automatically managed, saving application developers from having to manage the cache in their caching tier, and saving developers from having to worry about managing cache consistency or time-to-live of items in their cache. This is all managed and truly makes the lives of application developers so much easier!
The role of the KEEP Pool in True Cache
True Cache can be viewed as an extended buffer cache for the Oracle database, residing on separate machines to significantly enhance caching scale and capacity. It can truly increase the scale and capacity of caching for the database. For many types of operations, Oracle database uses the buffer cache to store data blocks read from the disk. True Cache is similar but operates at a larger scale. For the buffer cache you can use the KEEP pool to maintain frequently accessed segments in the buffer cache. The purpose of the KEEP buffer pool is to retain objects in memory, thus avoiding I/O operations.

Similarly, in order to indicate to True Cache that it should not evict (as much as possible) hot objects (frequently accessed, or objects that you want to be in the cache to avoid I/O operations), you can assign objects to the KEEP buffer pool on True Cache. (In fact, in more advanced setup if you have multiple true caches, you can assign different objects to the KEEP buffer pool on different True Caches).
True Cache’s KEEP Pool
Assigning objects to the KEEP pool in True Cache ensures efficient caching for frequently accessed data, enhancing performance by minimizing evictions. This improves the cache hit ratio for hot objects.

- Configure DB_KEEP_CACHE_SIZE on True Cache. To do this, you may need to compute an approximate size which really depends on the objects to be kept based on your application.
- Then you can assign objects on True Cache to the KEEP buffer pool. When an object is assigned to the KEEP buffer pool on True Cache, the object’s blocks are loaded for a query and then kept in the KEEP buffer pool.
- When new data is inserted into the object on the primary database, that new data is automatically propagated to the KEEP buffer pool on True Cache through the redo apply mechanism.
One thing to keep in mind is that – marking something KEEP on the primary database also marks it KEEP on True Cache. This can cause some confusion since you may not want the primary database keep objects to flood the True Cache keep pool.
Using DBMS_CACHEUTIL.TRUE_CACHE_KEEP will come to the rescue! This will take precedence and override objects that are marked as to be kept on the primary database.
As an example, to KEEP the CUSTOMER_LOOKUP table on True Cache, you can run
EXECUTE DBMS_CACHEUTIL.TRUE_CACHE_KEEP (‘SYS’, ‘CUSTOMER_LOOKUP’);
This will assign the object to the KEEP buffer pool on that cache.
Note, that you can also use DBMS_CACHEUTIL.TRUE_CACHE_UNKEEP() to remove objects from the KEEP buffer pool. But the block is not removed immediately. Instead, it will be naturally aged out as new blocks for other objects are brought into the KEEP buffer pool.
You can use the V$TRUE_CACHE_KEEP view to monitor which objects are assigned to the KEEP buffer cache for True Cache.
Conclusion
KEEP is a powerful feature to be able to pin specific tables and objects to ensure that your hot datasets are kept in cache and this prevents crucial data from being evicted due to memory constraints or by routine cache eviction. The data that is kept, is automatically refreshed, without developer intervention, and is kept consistent in real time as data is updated on the primary database. Use this capability to make it more efficient and performant to persist frequently accessed data in Oracle True Cache.
Overall, Oracle True Cache helps you boost performance and scalability by offloading resource intensive queries/reads from the primary database. It is the most fully featured SQL and Object Cache. Without developers taking on the burden of keeping data in sync between the cache and the primary database, data in True Cache is always kept consistent and current across multiple tables. Even schema changes in the primary database are automatically propagated to the cache.
Ready to optimize your caching strategy? Explore Oracle True Cache and unlock unparalleled performance today using Live Labs
Resources for further information:
True Cache home: https://www.oracle.com/truecache
User Guide: True Cache User Guide
Live Labs: How to access Live Labs for True Cache
Video: Video presentation
