1 TimesTen Application-Tier Database Cache Concepts

TimesTen Application-Tier Database Cache (TimesTen Cache) is an Oracle Database product option available with the TimesTen In-Memory Database. It is used as a database cache at the application tier to cache Oracle Database data and reduce the workload on the Oracle database. It also provides the connection and transfer of data between an Oracle database and a TimesTen database, as well as facilitating the capture and processing of high-volume event flows into a TimesTen database and subsequent transfer of data into an Oracle database.

You can cache Oracle Database data in a TimesTen database within cache groups. A cache group in a TimesTen database can cache a single Oracle Database table or a group of related Oracle Database tables.

This chapter includes the following topics:

Overview of cache groups

Cache groups define the Oracle Database data to be cached in a TimesTen database. A cache group can be defined to cache all or part of a single Oracle Database table, or a set of related Oracle Database tables.

Figure 1-1 shows the target_customers cache group that caches a subset of a single Oracle Database table customer.

Figure 1-1 Single-table cache group

Description of Figure 1-1 follows
Description of ''Figure 1-1 Single-table cache group''

You can cache multiple Oracle Database tables in the same cache group by defining a root table and one or more child tables. A cache group can contain only one root table.

In a cache group with multiple tables, each child table must reference the root table or another child table in the same cache group using a foreign key constraint. Although tables in a multiple-table cache group must be related to each other in the TimesTen database through foreign key constraints, the corresponding tables do not necessarily need to be related to each other in the Oracle database. The root table does not reference any table with a foreign key constraint. See "Multiple-table cache group" for more details about the characteristics of a multiple-table cache group.

While you may have multiple TimesTen databases that interact with the same Oracle database, they will each operate independently. Thus, any data cached in separate TimesTen databases will each interact with the Oracle database independently.

An Oracle Database table cannot be cached in separate cache groups within the same TimesTen database. However, the table can be cached in separate cache groups within different TimesTen databases. If the table is cached in separate AWT cache groups and the same cache instance is updated simultaneously on multiple TimesTen databases, there is no guarantee as to the order in which the updates are propagated to the cached Oracle Database table. In addition, the contents of the updated cache tables can be inconsistent on the separate TimesTen databases.

Cache instance

Data is loaded from an Oracle database into a cache group within a TimesTen database in units called cache instances. A cache instance is defined as a single row in the cache group's root table together with the set of related rows in the child tables.

Figure 1-2 shows three tables in the customer_orders cache group. The root table is customer. orders and order_item are child tables. The cache instance identified by the row with the value 122 in the cust_num primary key column of the customer table includes:

  • The two rows with the value 122 in the cust_num column of the orders table (whose value in the ord_num primary key column is 44325 or 65432), and

  • The three rows with the value 44325 or 65432 in the ord_num column of the order_item table

Figure 1-2 Multiple-table cache group

Description of Figure 1-2 follows
Description of ''Figure 1-2 Multiple-table cache group''

Cache group types

The most commonly used types of cache groups are:

  • Read-only cache group

    A read-only cache group enforces a caching behavior in which committed updates on cached tables in the Oracle database are automatically refreshed to the cache tables in the TimesTen database. Using a read-only cache group is suitable for reference data that is heavily accessed by applications.

    See "Read-only cache group" for details about read-only cache groups.

  • Asynchronous WriteThrough (AWT) cache group

    An AWT cache group enforces a caching behavior in which committed updates on cache tables in the TimesTen database are automatically propagated to the cached tables in the Oracle database in asynchronous fashion. Using an AWT cache group is suitable for high speed data capture and online transaction processing.

    See "Asynchronous WriteThrough (AWT) cache group" for details about AWT cache groups.

Other types of cache groups include:

  • Synchronous writethrough (SWT) cache group

    An SWT cache group enforces a caching behavior in which committed updates on cache tables in the TimesTen database are automatically propagated to the cached tables in the Oracle database in synchronous fashion.

    See "Synchronous WriteThrough (SWT) cache group" for details about SWT cache groups.

  • User managed cache group

    A user managed cache group defines customized caching behavior.

    For example, you can define a cache group that does not use automatic refresh or automatic propagation where committed updates on the cache tables are manually propagated or flushed to the cached Oracle Database tables.

    You can also define a cache group that uses both automatic propagation in synchronous fashion on every table and automatic refresh.

    See "User-managed cache group" for details about user managed cache groups.

Transmitting updates between the TimesTen and Oracle databases

Transmitting committed updates between the TimesTen cache tables and the cached Oracle Database tables keeps these tables in the two databases synchronized.

As shown in Figure 1-3, propagate and flush are operations that transmit committed updates on cache tables in the TimesTen database to the cached tables in the Oracle database. Flush is a manual operation and propagate is an automatic operation.

Load, refresh, and autorefresh are operations that transmit committed updates on cached tables in the Oracle database to the cache tables in the TimesTen database. Load and refresh are manual operations; autorefresh is an automatic operation.

See "Flushing a user managed cache group" for information about the FLUSH CACHE GROUP statement which can only be issued on a user managed cache group.

See "Asynchronous WriteThrough (AWT) cache group" and "Synchronous WriteThrough (SWT) cache group" for details about how a propagate operation is processed on AWT and SWT cache groups, respectively.

See "Loading and refreshing a cache group" for information about the LOAD CACHE GROUP and REFRESH CACHE GROUP statements.

See "AUTOREFRESH cache group attribute" for details about an autorefresh operation.

Figure 1-3 Transmitting committed updates between the TimesTen and Oracle databases

Description of Figure 1-3 follows
Description of ''Figure 1-3 Transmitting committed updates between the TimesTen and Oracle databases''

Loading data into a cache group: Explicitly loaded and dynamic cache groups

Cache groups are categorized as either explicitly loaded or dynamic.

  • In an explicitly loaded cache group, cache instances are loaded manually into the TimesTen cache tables from an Oracle database by using a load or refresh operation or automatically by using an autorefresh operation. The cache tables are loaded before operations such as queries are performed on the tables. An explicitly loaded cache group is appropriate when the set of data to cache is static and can be predetermined before applications begin performing operations on the cache tables. By default, cache groups are explicitly loaded unless they are defined as dynamic.

  • In a dynamic cache group, cache instances are loaded into the TimesTen cache tables on demand from an Oracle database using a dynamic load operation or manually using a load operation. A manual refresh or an autorefresh operation on a dynamic cache group can result in existing cache instances being updated or deleted, but committed updates on Oracle Database data that are not being cached do not result in new cache instances being loaded into its cache tables. A dynamic cache group is appropriate when the set of data to cache is small and should not be preloaded from Oracle Database before applications begin performing operations on the cache tables.

See "Transmitting updates between the TimesTen and Oracle databases" for details about cache group load and refresh operations.

See "Loading and refreshing a cache group" for more details about the differences between performing a load and a refresh operation on an explicitly loaded cache group and performing the same operations on a dynamic cache group.

See "Dynamically loading a cache instance" for details about a dynamic load operation.

Any cache group type (read-only, AWT, SWT, user managed) can be defined as an explicitly loaded cache group. All cache group types except a user managed cache group that uses both the AUTOREFRESH cache group attribute and the PROPAGATE cache table attribute can be defined as a dynamic cache group.

See "Dynamic cache groups" for more information about dynamic cache groups.

High availability caching solution

You can configure TimesTen Cache to achieve high availability of cache tables, and facilitate failover and recovery while maintaining connectivity to the Oracle database. A TimesTen database that is a participant in an active standby pair replication scheme can provide high availability for cache tables in a read-only or an AWT cache group.

An active standby pair provides for fault tolerance of a TimesTen database. Oracle Real Application Clusters (Oracle RAC) and Data Guard provides for high availability of an Oracle database.

See "Replicating cache tables" for information on configuring replication of cache tables.

See "Using TimesTen Cache in an Oracle RAC Environment" for more information on TimesTen Cache and Oracle RAC.

See "Using TimesTen Cache with Data Guard" for more information on TimesTen Cache and Data Guard.