gtpa2m24Application Programming

Deleting an Entry from a Logical Record Cache

To delete an entry from a logical record cache, the application starts the deleteCacheEntry function, passing the following as inputs:

The primary and secondary keys must exactly match the primary and secondary keys that are used to add the entry to cache. This includes both the content of the keys and their lengths. Additionally, the ECB must have the same DBI as the ECB that is used to add the entry. See Adding an Entry to a Logical Record Cache for more information about adding an entry to a logical record cache.

See TPF C/C++ Language Support User's Guide for more information about the deleteCacheEntry function.

The following shows the function to delete an entry from a logical record cache:

long  deleteCacheEntry(const cacheTokenPtr cache_to_update),
              const void  * primary_key,
              const long  * primary_key_length,
              const void  * secondary_key,
              const long  * secondary_key_length); 

If the target cache was defined with a primary and a secondary key, both a primary and secondary key must be provided on each call to the deleteCacheEntry function. If the cache was defined with a primary key only, then only a primary key should be passed. If a secondary key is provided, it is ignored by the deleteCacheEntry function.

If the target cache is a processor shared cache using the CF, the deleteCacheEntry function causes all other processors to have their copies of the deleted entry invalidated.

Examples

The following example shows how to delete an entry with primary and secondary keys defined in the processor shared cache that was created previously and how to cause any other processors with the same entry to have that entry marked as invalidated.

char  primaryKey[ ] = "delete the entry with this key";
char  secondaryKey[ ] = "using this secondary key";
long  primaryKeyL = 0;
long  secondaryKeyL = 0;
 
primaryKeyL = strlen( primaryKey );       /* get length of primary Key    */
secondaryKeyL = strlen( secondaryKey );   /* get length of secondary Key  */
 
if( deleteCacheEntry (
                    &myCacheShared,      /* addr of the token for the cache */
                     primaryKey,         /* primary key                     */
                    &primaryKeyL,        /* primary key length              */
                     secondaryKey,       /* secondary key                   */
                    &secondaryKeyL)      /* secondary key length            */
                      != CACHE_SUCCESS)  /* successful delete               */
    {
      printf("error deleting entry in Shared_Cache");  /* write message  */
      exit(1);                                         /* and exit       */
    }
 

The following example shows how to delete an entry with a primary key defined in a processor unique cache that was previously created with only primary keys.

strcpy( primaryKey,   "delete the entry with this key");
 primaryKeyL = strlen( primaryKey );              /* get length of primary Key*/
 
 if( deleteCacheEntry (
                    &myCacheUnique,       /* addr of the token for the cache */
                     primaryKey,          /* primary key                     */
                    &primaryKeyL,         /* primary key length              */
                     NULL,                /* no secondary key                */
                     NULL)                /* no secondary key length         */
                     !=CACHE_SUCCESS)     /* successful delete               */
     {
      printf("error deleting entry in Unique_Cache");  /* write message  */
      exit(1);                                         /* and exit       */
    }