/**
   * Get Search object from cache
   *
   * @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;
  }
 /**
  * Put Search object in cache
  *
  * @param id key
  * @param search the search to cache
  */
 public void putSearch(String id, Search search) {
   try {
     long time = System.currentTimeMillis();
     ByteArrayOutputStream bos = new ByteArrayOutputStream();
     GZIPOutputStream gzos = new GZIPOutputStream(bos);
     DataOutputStream oos = new DataOutputStream(gzos);
     search.write(oos);
     oos.flush();
     oos.close();
     gzos.close();
     long delta = System.currentTimeMillis() - time;
     ByteBufferWrapper wrap = new ByteBufferWrapper(bos.toByteArray());
     if (LOG.isDebugEnabled()) {
       LOG.debug("Compressing cache entry took: " + delta + "ms.");
       LOG.debug("size: " + wrap.getContents().length + " bytes");
     }
     cache.putInCache(id, wrap);
   } catch (IOException e) {
     LOG.info("cannot store object in cache: " + e);
   }
 }