@Test public void testRemoveAll() { cache.add(list); Collection<DatabaseDocument<TestType>> c = cache.removeAll(); assertEquals(2, c.size()); assertTrue(c.contains(doc1)); assertTrue(c.contains(doc2)); assertNull(cache.getDocumentById(id1)); assertNull(cache.getDocumentById(id2)); assertEquals(0, cache.removeAll().size()); }
@Override public Collection<DatabaseDocument<T>> removeAll() { List<DatabaseDocument<T>> list = new ArrayList<DatabaseDocument<T>>(); for (DatabaseDocument<T> d : map.values()) { list.add(d); } map.clear(); lastTouched.clear(); return list; }
MemoryCache implements Cache<T> { @Override public Collection<DatabaseDocument<T>> removeAll() { List<DatabaseDocument<T>> list = new ArrayList<DatabaseDocument<T>>(); for (DatabaseDocument<T> d : map.values()) { list.add(d); } map.clear(); lastTouched.clear(); return list; } }
MemoryCache implements Cache<T> { @Override public Collection<DatabaseDocument<T>> removeAll() { List<DatabaseDocument<T>> list = new ArrayList<DatabaseDocument<T>>(); for (DatabaseDocument<T> d : map.values()) { list.add(d); } map.clear(); lastTouched.clear(); return list; } MemoryCache(); }
MemoryCache implements Cache<T> { @Override public Collection<DatabaseDocument<T>> removeAll() { List<DatabaseDocument<T>> list = new ArrayList<DatabaseDocument<T>>(); for (DatabaseDocument<T> d : map.values()) { list.add(d); } map.clear(); lastTouched.clear(); return list; } MemoryCache(); @Override void prepare(); @Override void add(DatabaseDocument<T> doc); @Override void add(Collection<DatabaseDocument<T>> docs); @Override DatabaseDocument<T> remove(DocumentID<T> id); @Override Collection<DatabaseDocument<T>> removeAll(); @Override DatabaseDocument<T> getDocumentById(DocumentID<T> id); @Override DatabaseDocument<T> getDocument(); @Override DatabaseDocument<T> getDocument(DatabaseQuery<T> query); @Override ArrayList<DatabaseDocument<T>> getDocument(DatabaseQuery<T> query,
			int limit); @Override DatabaseDocument<T> getAndTag(DatabaseQuery<T> query, String ... tags); @Override Collection<DatabaseDocument<T>> getAndTag(DatabaseQuery<T> query,
			int n, String ... tags); @Override boolean update(DatabaseDocument<T> document); @Override boolean markTouched(DocumentID<T> id, String tag); @Override int getSize(); @Override Collection<DatabaseDocument<T>> removeStale(int stalerThanMs); @Override boolean freshen(DocumentID<T> id); }
MemoryCache implements Cache<T> { @Override public Collection<DatabaseDocument<T>> removeAll() { List<DatabaseDocument<T>> list = new ArrayList<DatabaseDocument<T>>(); for (DatabaseDocument<T> d : map.values()) { list.add(d); } map.clear(); lastTouched.clear(); return list; } MemoryCache(); @Override void prepare(); @Override void add(DatabaseDocument<T> doc); @Override void add(Collection<DatabaseDocument<T>> docs); @Override DatabaseDocument<T> remove(DocumentID<T> id); @Override Collection<DatabaseDocument<T>> removeAll(); @Override DatabaseDocument<T> getDocumentById(DocumentID<T> id); @Override DatabaseDocument<T> getDocument(); @Override DatabaseDocument<T> getDocument(DatabaseQuery<T> query); @Override ArrayList<DatabaseDocument<T>> getDocument(DatabaseQuery<T> query,
			int limit); @Override DatabaseDocument<T> getAndTag(DatabaseQuery<T> query, String ... tags); @Override Collection<DatabaseDocument<T>> getAndTag(DatabaseQuery<T> query,
			int n, String ... tags); @Override boolean update(DatabaseDocument<T> document); @Override boolean markTouched(DocumentID<T> id, String tag); @Override int getSize(); @Override Collection<DatabaseDocument<T>> removeStale(int stalerThanMs); @Override boolean freshen(DocumentID<T> id);  }