| Javazoid Links |
Javazoid updated Sept 1 2001 |
| Home
of In Feb 2000, my Java IDE FrenchRoast won honorable mention in the 2nd JavaWorld CodeMasters series. Oct 2000 Below is a work in progress... a version of Minesweeper. You could also win a million bucks playing Minesweeper.
|
Cachebuilding a simple object cache... Someone I work with suggested that implementing an object cache would be a difficult and bug-prone endeavor. I thought it should be straightforward. As I saw it, the basic implementation of an object cache should meet these requirements: The package com.javazoid.cache consists of 4 classes: Cache - A decorator for a hashtable, which would allow the developer/user to add, remove and get items. The constructor for this class is private and so the only way to create an instance is to call the static createCache() method, which returns the one and only instance. CacheItem - Basically, another wrapper for the object that is to get inserted into the Cache. The CacheItem provides a timeout field, which is about the only reason this class is required. CacheManager - A kind of visitor object that gets created when the Cache itself is created. This object lives on a separate thread and spends most of its life asleep. Occasionally it wakes up and throws old objects out of the Cache. CacheTest - My belief is that no component or package should be created without some capability for testing. This type of class also allows the developer to get a feeling for the robust nature of the component -- in other words, how much more testing is required before the component is production-worthy.
Challenges Any questions, please contact me ggallant@bigfoot.com . Copyright (c) Gervase Gallant 1999,2000,2001. |