flushCache: Flush the contents of a cache
This function removes all entries from a logical record cache.
Last updated
- Changed in 2022.
- Changed in 2019.
- Changed for PUT13.
Format
#include <tpf/c_cach.h>
int flushCache(const cacheToken *cache_to_flush);
- cache_to_flush
- The cache token for the logical record cache to be flushed.
Normal return
- CACHE_SUCCESS
- The function is completed successfully.
Error return
- CACHE_ERROR_HANDLE
- The cache token that was specified for the cache_to_flush parameter is not valid.
- CACHE_ERROR_CASTOUT
- The castout program or castout function failed too many times for a specific entry. When this error is returned, some entries might already be removed from the cache before this error scenario was encountered.
Programming considerations
- The flush occurs immediately and without regard for any other applications that might also be using the cache.
- The flushCache function removes all entries from the cache, even if those entries were added by an application that is running in a different subsystem than the application that called the flushCache function.
- Use the newCache, tpf_newCache_ext, or tpf_cacheNameToToken function to retrieve a logical record cache token.
- For more information about when caches are re-created and reattached after an IPL, see Logical record cache IPL considerations.
- When each entry is removed, logical record cache processing calls the castout function or program for any entries with a castout function or program defined.
Examples
The following example flushes the contents of a cache that
is named MYCACHE.
#include <tpf/c_cach.h>
cacheToken cacheToken;
int rc;
// Retrieve the cache token.
rc = tpf_cacheNameToToken("MYCACHE", &cacheToken);
if (rc != CACHE_SUCCESS)
{
printf(“tpf_cacheNameToToken() returned unexpected return code %d\n”, rc);
exit(0);
}
// Flush the cache.
rc = flushCache(&cacheToken);
if (rc != CACHE_SUCCESS)
{
printf(“flushCache() returned unexpected return code %d\n”, rc);
}