A timed Cache
Just a quick note about something that i did at work which is a cool pattern – A Timed Cache. We have some files which get loaded from a db and the db can change periodically – everything is readonly.
the simple solution is to have a timeout period and when you check the cache to see if something is loaded you also check the current time and the time you last cleared the cache, if the difference is greater than the timeout period then you simply clear the cache first.
this all happens inside a synchronized method which i am fairly certain about but which i’d like to do some more experimentation with to be sure – another post! I will probably set up some kind of multithreaded test environment where i can really see whats going on once and for all – its quite hard to conceptualise all this synchronised stuff in your head – its all very well in theory:)
