next up previous contents
Next: Other Base Services Up: The Basic Services Previous: Future Improvements

The HsCache Service

  As discussed in Chapter gif, the HDM at times makes reference to external sources of information. This allows the HDM to remain compact in size, but still robust enough to handle the variety of objects that a user may want to archive.

Recall that the Promise classes provide the mechanism for ``re-generating'' Needle data dynamically. This is inefficient, however, if the the same Promise is repeatedly asked to generate the same data. As a solution, Haystack provides a mechanism for caching data created by a Promise. Optionally, a programmer may modify the getData() operation for a Needle so that as data is being generated by the Promise it is simulatenously being sent to disk for temporary caching. The Needle requests this disk space by calling the allocateCache(key) command on the HsCache, where key is the Needle's ID.

When HsCache receives a request it returns a special extension of the Java stream Writer class, CacheFileWriter. This extension overrides a number of the Writer's functions so that the HsCache can check to see if the cache space is in use.

After the Needle has placed the data in the cache, it can request that the HsCache open a Reader to that cache space (a Promise holding Needle returns a Reader when getData() is invoked). This reader is also an extension to the standarad Reader class and is called CacheFileReader. As data is read using the CacheFileReader the ``life'' of the item in the cache is extended. As soon as data is not being actively read, the file will be removed after a period of five to ten minutes.



Copyright 1998, Eytan Adar (eytan@alum.mit.edu)