Overview

This module provides an implementation of a feature cache.

It started out as a Google Summer of Code project:

It has since been revived to be used in a WFS caching datastore for uDig.

Class Diagram

 

Feature Cache Implementations

There are currently two implementations of feature cache:

GridFeatureCache

StreamingGridFeatureCache

Spatial Index Implementations

 GridSpatialIndex

Eviction Policy

LRUEvictionPolicy

Storage Implementations

There are currently three storage implementations:

MemoryStore

DiskStore

BufferedDiskStore

Usage

So you have a feature source that you want to cache . . .

A FeatureCache can be made using:

 FeatureCache cachingFS = new StreamingGridFeatureCache(featureSource, indexcapacity, featurecapacity, storage);

The above constructor makes use of the bounds of the featureSource for determing the bounds of the cache.  If you wish to provide your own bounds for the cache you can do so using the following:

FeatureCache cachingFS = new StreamingGridFeatureCache(featureSource, bounds, indexcapacity, featurecapacity, storage);

Re-using the Cache

A cache store can be re-used and providing the feature types are the same the features from the store will be used.  For example if you are using this within uDig; cache a bunch of WFS features; restart uDig; the feature cache will still be used to serve up features.

Clearing the Cache

Currently there is no policy for checking if features in the cache are valid.  Features in the cache do not expire.  However the feature cache does listen to feature events and if a feature is added or removed from the cache the nodes that correspond to that feature event are invalidated and cleared.  (Thus next time features from those nodes are requested it will pass the request along to the original feature source). 

The cache can be cleared manually using:

FeatureCache.clear()