The server side of this design is a cache pipeline wrapped by a GWT RPC service. Today I attempted to implement this.
First I built up the cache pipeline. This was a simple design with each cache stage basically the code below.
public V get(K key) {
V value = cacheActual.get(key);
if (value == null) {
if (nextStage != null) {
value = nextStage.get(key);
if (value != null) {
cacheActual.put(key, value);
}
}
}
return value;
}
public void put(K key, V value) {
V val = cacheActual.get(key);
if (!(val != null && val.equals(value))) {
cacheActual.put(key, value);
if (nextStage != null) {
nextStage.put(key);
}
}
}
Building this up took 5 Java classes
- CacheStage.java (the code above)
- CachePipeline.java (hooks together CacheStage's in a pipeline)
- CacheActual.java (interface for actual caches)
- CacheCache.java (memcache implementation)
- CacheDB.java (datastore + web-service implementation with datastore intially stubbed)
Next I wrapped this a GWT style RPC server. This took some classes
- PersonService.java (interface for class containing the RPC call)
- PersonServiceAsync.java (async version of PersonService.java)
- PersonServiceImpl.java (server side implementation of PersonService.java)
- PersonClient.java (the client-side person class)
- PersonFetch.java (person + tracking data to cross-reference to requests, required for best-effort operation)
- PersonClientGroup.java (a class to wrap all the data returned by the RPC call)
- PersonTrait.java (since the server and client person classes differ, we need to specify the canonical person traits such as name, address, uniqueID, and have all person classes implement this interface)
You can watch this project's progress here.
0 comments:
Post a Comment