The dr_cache_refresh function provides a way to refresh a cache entry when the plug-in requires it. This refresh can be achieved by passing NULL for the ref parameter in dr_cache_init and by passing DR_CHECK in a dr_net_write call. If DR_CHECK is passed to dr_net_write and it returns with DR_EXPIR, the plug-in should generate new content in the entry and call dr_cache_refresh with that entry before calling dr_net_write again to send the response.
You can use the plug-in to replace the cached entry even if it has not expired based on some other business logic. The dr_cache_refresh function is useful in this case. The plug-in then does the cache refresh management actively.
PRInt32 dr_cache_refresh(DrHdl hdl, const char *key, PRUint32 klen, PRIntervalTime timeout, Entry *entry, Request *rq, Session *sn);
1 if successful.
0 if an error occurs.
Persistent handle created by the dr_cache_init function.
Key to cache, search, or refresh.
Length of the key in bytes.
Expiration time of this entry. If a value of 0 is passed, the maxAge value passed to dr_cache_init is used.
The not NULL entry to be cached.
Pointer to the request.
Pointer to the session.
Entry entry; char *key = "MOVIES" GenNewMovieList(&entry.data, &entry.dataLen); // Implemented by // plugin developer if(!dr_cache_refresh(hdl, key, strlen(key), 0, &entry, rq, sn)) { ereport(LOG_FAILURE, "dr_cache_refresh() failed"); return REQ_ABORTED; }