Table 8-1. GCacheFactory expiration values
Expires after a relative number of seconds have passed
Expires after a relative number of milliseconds have
Absolute date in time as a java.util.Date
As you move along in the code take note of where you set the key and value strings
that you're putting in the cache. It's important to realize that you're not restricted to just
Strings as objects in the cache. You can put any serializable object in the cache.
Take a look at the code in Listing 8-3. Here you are accessing the
ConfigurationStatistics class to query some metrics on how many times your cache
has been accessed, or hit.
Listing 8-3. Cache statistics
CacheStatistics stats = cache.getCacheStatistics();
int hits = stats.getCacheHits();
It's time to test out the application. Run it as a local web application. Since you're
not using GWT, Eclipse will start a local web server and assign it a port. In most cases,
unless you've reconfigured Eclipse, the address should be http://localhost:8080.
Open the application. You should see something similar to Figure 8-2.
Figure 8-2. Welcome page (index.html)