Chapter 9. Caching

Table of Contents

Cache transformation
Introduction
Cache configuration
Table and cache statistics
Select statement
Insert statement
Update statement
Delete statement
Cache Initialization

Caching affects the behaviour of the DO class. If checked, all DO instances (their original DataStruct objects) are stored in the cache inside the DO class. Subsequent queries of the table use the Query class for queries. The results of all Queries are complete.

Cache transformation

Since DODS 5.1 final, the DO cache is transformed into DataStruct cache. Instead of the whole DOs, only their original DataStructs are added to new DataStruct cache.

DO has had only one data (DataStruct object) and all transformations were done on this object. DataStruct object contains values of columns of one table row. Now, DO holds 2 DataStruct-references:

  • originalData

  • data

The originalData holds original data (that was read from the database). This is never modified till commit, and this DataStruct object is added to DataStruct cache, if this cache exists.

The second, data, is only created (by copying the first one) if data is modified. If the second DataStruct exists, the DO's attribute isDirty is set to true. Even if after some modifications the new DataStruct holds exactly the same values as the original one, the DO is still dirty. So there is no way back from isDirty=true to isDirty=false (except during commit of the transaction). If the transaction is committed, the new DataStruct is moved in the place of the original one. The new DataStruct is NULL again, so the attribute isDirty becomes false again.

A newly created DO (in memory, not from the database) will just have a DataStruct object data. Data values in DataStruct object originalData is null before the commit().

The oid and the version attributes are moved from DO to DataStruct object.

New attributes added in DataStruct object are:

  • isEmpty

- type: boolean

- default value: true

Since originalData is being constructed for every DO, this flag "knows" if DataStruct has any useful content. If there is no data in DataStructs - except oid, this attribute is true, otherwise false.

  • databaseName

- type: String

- default value: null

The logical database to which this DataStruct belongs to.

New methods added in DataStruct object are:

  • getOId()

Returns DataStruct's identifier.

  • setDatabase(String dbName)

Sets attribute databaseName.

  • getDatabase()

Returns attribute databaseName.

  • getHandle()

Returns this DataStruct's handle (identifier as a string).

  • getCacheHandle()

Returns this DataStruct's cache handle (String in the form: "<database_name>.<indentifier_as_String>").

  • get and set methods for every table column

In DO class are added new methods that work with originalData:

  • originalData_get<column_name>()

Returns the row value of the column <column_name> of the DO's originalData object.

  • originalData_set(Object data)

Sets the DO's originalData object.

  • getData()

Returns DO's DataStruct object. If DO's data object exists, returns that object, otherwise returns DO's originalData object.

  • originalData_get()

Returns DO's originalData object.

  • getOriginalVersion()

Returns the current version of DO's originalData object.