java - Pre-populating a cache with Spring's JSR-107 annotations -
i have table often-read, rarely-changed records (about 50,000) need cache. i'd pre-populate cache @ server startup time single query loading records. i'm not sure what's best way when using spring's annotations. way found apparent docs load entities in 1 service method pass them method in service annotated @cacheput , doesn't else.
preloaderservice: @autowired private cacheservice cacheservice; public void getallwidgets() { list<widget> widgets = ... load them in 1 query (widget widget: widgets) { cacheservice.populate(widget); //must call different class spring's proxy @cacheput gets used } } cacheservice: @cacheput public void populate(@cachevalue widget widget){ //do nothing else, need caching annotations processed } the above doesn't appear elegant me cannot see way. way, i'm using ehcache in case lower-level api achieve this.
Comments
Post a Comment