gtpc2m1g | C/C++ Language Support User's Guide |
This function deletes a cache entry.
Format
#include <c$cach.h>
long deleteCacheEntry(const cacheToken *cache_to_delete,
const void *primary_key,
const long *primary_key_length,
const void *secondary_key,
const long *secondary_key_length);
- cache_to_delete
- The returned cache_token from the newCache function that
created the logical record cache.
- primary_key
- A pointer to a field that contains the value of the primary key.
- primary_key_length
- The length of the primary key for a cache entry. The length
specified must be equal to or less than the maximum value specified for the
newCache function.
- secondary_key
- A pointer to a field that contains the value of the secondary key.
If a secondary key was not specified for the newCache function,
this field is ignored and will contain a NULL pointer.
- secondary_key_length
- The length of the specified secondary key. The length specified
must be equal to or less than the maximum value specified for the
newCache function.
Normal Return
- CACHE_SUCCESS
- The function is completed successfully.
Error Return
One of the following:
- CACHE_ERROR_HANDLE
- The cache_token provided for the cache_to_delete parameter is not
valid.
- CACHE_ERROR_PARAM
- The value passed for one of the parameters is not valid.
Programming Considerations
- To ensure data integrity, the caller must ensure that a locking mechanism
is used when using the deleteCacheEntry function.
- Primary and secondary keys must exactly match the primary and secondary
keys used to add the entry to the cache.
- The entry control block (ECB) must have the same database ID (DBI) as the
ECB used to add the entry.
- If the target cache is a processor shared cache using CF, all other
processors will have their copies of the deleted entry invalidated.
Examples
The following example deletes a cache entry from the file system INODE
cache if it exists.
#include <c$cach.h>
#include <i$glue.h
struct icontrol * contrl_ptr; /* pointer file system control area */
const long primaryKeyLgh = sizeof(ino_t); /* INODE number is key */
long nodeord; /* INODE number */
/* get pointer to file system control area */
contrl_ptr = cinfc_fast_ss(CINFC_CMMZERO,
ecbptr()->ce1dbi );
/* if using INODE cache, call to delete possible old entry for this INODE */
if (contrl_ptr->icontrol_icacheToken.token1 != 0)
deleteCacheEntry(&contrl_ptr-;>icontrol_icacheToken,
&nodeord,
&primaryKeyLgh,
NULL,
NULL);
Related Information