Query cache mechanism
I implemented a simple query cache system in metacat. The core of the cache is a Hashtable. The key of Hashtable is a string which inlcudes selection sql query, return doc type and return fields. The value of Hashtable is a string of result set in xml format. Before running sql query, metacat will look up this Hashtable. If the key was found, the value from Hashtable will be returned to the client. So sql query would NOT be run and it can save time.
Here are some features:
1) Cache mechanism can be turned on/off in metacat.properties.
2) The default size of cache is 1000, and it is configurable.
3) Cache mechanism is synchronized and is muti-thread safe.
4) When cache is full, the records in cache will be clear.
5) When an inserting, updating, or deleting (including replication) happens, the cache will expire (everything in the cache will be clear).
6) In order to simplify the access control, the cache mechanism only works for public user.