MemResultStore.java [src/csip] Revision: default  Date:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package csip;

import csip.utils.LRUCache;
import org.codehaus.jettison.json.JSONArray;

/**
 *
 * @author od
 */
class MemResultStore implements ResultStore {

  LRUCache<String, JSONArray> cache;


  MemResultStore(int limit) {
    cache = new LRUCache<>(limit);
  }


  @Override
  public synchronized JSONArray getResult(String digest) {
    return cache.get(digest);
  }


  @Override
  public synchronized void putResult(String digest, JSONArray results) {
    cache.put(digest, results);
  }


  @Override
  public synchronized void purge() {
    cache.clear();
  }


  @Override
  public void close() throws Exception {
  }

}