cache package


Package Contract

This package includes the classes that provide the data store for all the HTML pages fetched and approved by the Ferrets. It consists of two classes- Cache and FerretApprovedPagesCache.

The data store used for storing all the pages fetched by the Ferret is known as the FerretLookupCache and is an object of type Cache. Before a Ferret goes out on the Internet to search for a particular page, it first checks this cache to see if that page has already been fetched before.

The data store used for storing all the pages approved by the Ferret is an object of type FerretApprovedPagesCache. This class extends the Cache class and provides additional functionality of informing the Filter of the arrival of a new HTML page approved by the Ferret.

Package-Level CRC

Collaborators:
filter, ferret

Responsibilities:
Store pages approved by ferrets.

Class-Level CRC

The cache package contains the following classes:

* Cache
* FerretApprovedPagesCache

Class Cache

* Responsibilities:
This class is basically the data store for all the HTML pages fetched by the Ferrets. It consists of a hashtable keyed by the HTML Page URL and containing a reference to the PageAttribute object of the corresponding HTML page. The PageAttribute class contains all the possible attributes that a HTML page can have. These attributes are filled in by each actor starting from the Ferret, then the Filter, the Analyzer and finally the WebpageDB.
The Ferret is responsible for adding entries into this data store. Entries will be purged by the Purger. This Cache class serves as the cache used to store all the HTML pages fetched by the Ferrets (it is known as the FerretLookupCache). This class is extended by the FerretApprovedPagesCache, which has the added functionality of notifying the Filter when a new Ferret approved HTML page is stored in its data store.
* Collaborators:
Class Ferret
* Variables and Methods:
public PageAttribute get(URL pageURL)
This is used to retrieve the PageAttribute object from the cache given the URL of the page.
public synchronized void put(URL pageURL, PageAttribute incomingPageAttribute)
This method fills in the cache with entries of PageAttribute objects for each page got by the ferrets. It is called by the Ferrets when a Page is fetched and also when it is approved.
public synchronized PageAttribute remove(URL pageURL)
This method is used to purge the cache.

Class FerretApprovedPagesCache

* Responsibilities:
This class represents the data store for all the HTML pages approved by the Ferrets. It extends the Cache class.
This class adds functionality to the basic Cache class by overriding the put() method of the Cache class so that this method also informs the Filter of the arrival of a new Ferret Approved Page's PageAttribute in its (FerretApprovedPagesCache's) data store. To be able to do this it gets a reference to the filter class in its constructor.
* Collaborators:
ferret, Class Filter
* Variables and Methods:
public FerretApprovedPagesCache(Filter filter)
This constructor gets a reference to the Filter object. It needs this reference to inform the filter of the arrival of a new Ferret Approved Page.
public synchronized void put(URL pageURL, PageAttribute, incomingPageAttribute)
This calls the super class's put() method to insert a new FerretApproved PageAttribute into the internal data store. In addition it also informs the Filter of the arrival of this new PageAttribute by invoking the processNewPageArrival() method of the Filter.

Message Interactions


Message Interactions with other packages
* With ferret
Ferret calls the get() method of the Cache Ferret calls the put() method of the Cache. Ferret calls the put method of the FerretApprovedPagesCache.
* With filter
The FerretApprovedPagesCache class's put() method calls the filter's informNewPageArrival() method of the filter.
last | | to sitemap | | up one level | | next