* @param id key
* @return
* @throws NeedsRefreshException
*/
public Search getSearch(String id, ServiceLocator locator) throws NeedsRefreshException {
Search search=null;
ByteBufferWrapper w=(ByteBufferWrapper)cache.getFromCache(id);
if(w!=null){
try {
long time=System.currentTimeMillis();
ByteArrayInputStream is=new ByteArrayInputStream(w.getContents());
GZIPInputStream gs = new GZIPInputStream(is);
DataInputStream dis = new DataInputStream(gs);
search = new Search(locator);
search.readFields(dis);
long delta=System.currentTimeMillis()-time;
if(LOG.isDebugEnabled()){
LOG.debug("Decompressing cache entry took: " + delta + "ms.");
}
search.init();
} catch (IOException e) {
LOG.info("Could not get cached object: " + e);
}
}
return search;