Sun Java System Web Server 7.0 Update 4 NSAPI Developer's Guide

dr_cache_refresh() Function

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);

Return Values

1 if successful.

0 if an error occurs.


DrHdl hdl

Persistent handle created by the dr_cache_init function.

const char *key

Key to cache, search, or refresh.

PRUint32 klen

Length of the key in bytes.

PRIntervalTime timeout

Expiration time of this entry. If a value of 0 is passed, the maxAge value passed to dr_cache_init is used.

Entry *entry

The not NULL entry to be cached.

Request *rq

Pointer to the request.

Session *sn

Pointer to the session.


Entry entry;
char *key = "MOVIES"
GenNewMovieList(&, &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;