Friday, June 25, 2010

Define Key for LogicCache

Hi, let`s speak about what key for LogicCache. Ok, not for LogicCache, for any cache.
Cache like a Map, there is key and related value. When we ask cache for a value we write the next code:
cache.get(key);
and there is a comparison like keyInsideCache.equals(key) so key`s class must override equals and hashCode.
A key may be stored to a disk store in the serialized form, so key`s class and all key`s properties`s classes must implement the java.io.Serializable interface.
Any key must contain a set of properties which influence to the result and make key unique.

In accordance to the requirements above LogicCacheKey was designed. Here is the class "diagram" :)

















LogicCacheKey contains several properties:

  • patientId - marks result for certain patient;
  • indexDate - date, LogicContext had when result was cached. We can run LogicService.eval for the past time and now. There is method updateTime which set to zero milli-/seconds, minutes, hours because of when we put "past time" we will write dd/MM/yyyy, and no HH:mm:ss.
  • dataSource - only contains canonical name of the class of the LogicDataSource implementation. We don`t need any information dataSource contains.
  • criteria - LogicCriteria which is parsed from string representation of Rule we run eval method for. I think about how to make it string which will reprpesent LogicCriteria, like dataSource.
  • parameters - some additional parameters. If this map will contain some non-serializable objects will only will not have this cache-entry stored to disk store.

No comments:

Post a Comment