Centralizing application logic

time to read 2 min | 226 words

Okay, last post for today.

In my current project, I've a class that is the center point for the rest of the system. It's not a Blob, but rather delegate to a lot of other classes and methods to do the work. It's sort of like a facade over the system, but for the system itself. I now find myself in the position where I need to provide some caching support for data that I pull from the database.

The issue is that while the application itself is a web application, I'm trying very hard to make sure that it doesn't depend on the web itself to do its work. But the caching that I need is for something that I need only on certain requests, but then definately need it (currently it makes 21 calls to load the same information). When the request end, I want the cache to go away.

This is very easy on the web, since I can use the current request to store the items, but this cause problems with both non-web usages (which is possible) and while using tests. I'm currently thinking of using some sort of per thread LRU hash table. I'm not very happy about it, though, so any ideas would be welcome.