xtim
Wednesday, September 17, 2008
 
Persistent caches in Spring
The S3StorageManager is now picking up page images, word maps and links from S3 - woohoo! The next step is to enable caching so that it doesn't have to fetch a page image multiple times. The web servers will have plenty of free disk space so I'd like to use that to cache the objects from S3.

I had planned to use the AOP caching mechanism in Spring to take care of this automatically, storing objects in a persistent EHCache on the disk. Everything's configured and I can see the images getting pushed into the persistent cache, but they're never found again once you restart the application - so we'd get the benefits of caching while the app is running, but a site update or restart would mean we'd have to rebuild the cache from scratch.

A bit of poking around reveals that the CacheInterceptor is prepending the oject id of the target object to the cache key. I can see why that's a good idea (you probably do want to partition the method results cache contents by target most of the time), but it means that results cached from one object won't be used once that particular instance object's been replaced. In our case the target is a singleton anyway so we don't get any benefit.

I think the best solution might be for our S3StorageManager to manage its own cache explicitly. Off to check the EHCache documentation...

T

Labels: , ,


Comments: Post a Comment

<< Home

Powered by Blogger