@Test public void testGetAndTag() { cache.add(list); assertEquals(doc1, cache.getAndTag(q1, "tag")); InOrder inOrder = inOrder(doc1, q1); inOrder.verify(q1).requireNotFetchedByStage("tag"); inOrder.verify(doc1).setFetchedBy(eq("tag"), any(Date.class)); }
@Override public DatabaseDocument<T> getAndTag(DatabaseQuery<T> query, String ... tags) { for(String tag : tags) { query.requireNotFetchedByStage(tag); } DatabaseDocument<T> doc; synchronized (this) { doc = getDocument(query); if (doc != null) { freshen(doc.getID()); for(String tag : tags) { doc.setFetchedBy(tag, new Date()); } } } return doc; }
MemoryCache implements Cache<T> { @Override public DatabaseDocument<T> getAndTag(DatabaseQuery<T> query, String ... tags) { for(String tag : tags) { query.requireNotFetchedByStage(tag); } DatabaseDocument<T> doc; synchronized (this) { doc = getDocument(query); if (doc != null) { freshen(doc.getID()); for(String tag : tags) { doc.setFetchedBy(tag, new Date()); } } } return doc; } }
MemoryCache implements Cache<T> { @Override public DatabaseDocument<T> getAndTag(DatabaseQuery<T> query, String ... tags) { for(String tag : tags) { query.requireNotFetchedByStage(tag); } DatabaseDocument<T> doc; synchronized (this) { doc = getDocument(query); if (doc != null) { freshen(doc.getID()); for(String tag : tags) { doc.setFetchedBy(tag, new Date()); } } } return doc; } MemoryCache(); }
MemoryCache implements Cache<T> { @Override public DatabaseDocument<T> getAndTag(DatabaseQuery<T> query, String ... tags) { for(String tag : tags) { query.requireNotFetchedByStage(tag); } DatabaseDocument<T> doc; synchronized (this) { doc = getDocument(query); if (doc != null) { freshen(doc.getID()); for(String tag : tags) { doc.setFetchedBy(tag, new Date()); } } } return doc; } 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 DatabaseDocument<T> getAndTag(DatabaseQuery<T> query, String ... tags) { for(String tag : tags) { query.requireNotFetchedByStage(tag); } DatabaseDocument<T> doc; synchronized (this) { doc = getDocument(query); if (doc != null) { freshen(doc.getID()); for(String tag : tags) { doc.setFetchedBy(tag, new Date()); } } } return doc; } 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);  }