classname_set_caching_priority

Change the caching priority for this class.

Prototype

 
    MCO_RET	classname_set_caching_priority(	/*IN*/ mco_trans_h t, 
                             /*IN*/ int priority );
 

Arguments

t A MCO_READ_WRITE transaction handle returned by mco_trans_start()
priority An integer value specifying the priority (see description below)

Description

This function is generated only for persistent classes. A cache priority property value on each cache page improves on the basic Least Recently Used (LRU) cache policy for flushing cache pages by allowing applications to influence how long certain pages remain in the disk manager cache. When the LRU algorithm locates a "victim", instead of immediately releasing the page (removing the page from the tail of the L2 link list), the algorithm inspects its caching_priority field. If the value is not zero, the caching_priority is decremented and the page is re-linked to the beginning of the L2-list. A caching priority of zero means the default behavior. A caching priority of 1 indicates that the page will be moved from the head to the tail of the LRU list twice. A caching priority 2 means three loops through the LRU list, and so on. The higher the priority, the longer the page remains linked to the LRU list (stays in cache).

At the time the database is created, the application can assign priorities to indexes, memory allocator bitmap pages and object pages (excluding BLOBs). The priorities are assigned through the mco_db_params_t structure index_caching_priority, allocation_bitmap_caching_priority and objects_caching_priority fields. By default all pages have the same priority (zero).

This function makes it possible to change the caching priority for a class at runtime. Using the preset object priority as a baseline, the relative priorities of some classes can be adjusted. For example, large and rarely accessed objects can be assigned lower priority, while small frequently accessed classes can be assigned a higher priority. The caching priority assigned at runtime is stored in the database and is used until it is explicitly overwritten. For further details see the Persistent Database I/O page.

Return Codes

MCO_S_OK The caching priority was set successfully

Example

 
    Schema snippet:
        
     
    declare database hybriddb;
     
    transient class A 
    {
        unsigned<4> ui4;
        ...
    };
     
    persistent class B 
    {
        unsigned<4> ui4;
        ...
    };
     
    Application snippet:
        
     
    const char * db_name = "hybriddb";

 
    int main(int argc, char* argv[])
    {
        MCO_RET rc = MCO_S_OK;
        mco_db_h db = 0;
        mco_trans_h t;
        ...
         
         B b;
        ...
         {
            rc = mco_trans_start( db, MCO_READ_WRITE, MCO_TRANS_FOREGROUND, &t );
         
            ...
         
            rc = B_set_caching_priority( t, 1 );
        
         
            ...
         
        }