class AsyncListenerExample {

  public static void example() throws InterruptedException {
    final StringDAO stringDAO = new StringDAO();
    final Cache<String, String> cache = CacheBuilder.heapCache()
        .evictionListener(new ScheduledEvictionListener<String, String>() {
          @Override
          public void save(List<CacheTask<String, String>> cacheTasks) {
            for (final CacheTask<String, String> task : cacheTasks) {
              stringDAO.update(task.getKey(), task.getValue());
            }
          }
        }).build();
    cache.put("key", "value");
  }

}