class ExpiringSet {

    public boolean contains(final E key) {
        synchronized (set) {
            if (set.contains(key)) {
                return true;
            }
            set.add(key);   // not found, so add it
        }
        scheduler.schedule(new Runnable() {   // schedule automatic key removal
            @Override
            public void run() {
                synchronized (set) {
                    set.remove(key);
                }
            }
        }, expireSeconds, TimeUnit.SECONDS);
        return false;
    }

    public  ExpiringSet(int expireSeconds);

}