@Test public void testMarkTouched() { cache.add(doc1); assertTrue(cache.markTouched(id1, "tag")); verify(doc1).setTouchedBy(eq("tag"), any(Date.class)); assertFalse(cache.markTouched(id2, "tag2")); verifyNoMoreInteractions(doc2); }
@Override public boolean markTouched(DocumentID<T> id, String tag) { DatabaseDocument<T> inCache; synchronized (this) { inCache = getDocumentById(id); if (inCache != null) { freshen(inCache.getID()); inCache.setTouchedBy(tag, new Date()); return true; } } return false; }
MemoryCache implements Cache<T> { @Override public boolean markTouched(DocumentID<T> id, String tag) { DatabaseDocument<T> inCache; synchronized (this) { inCache = getDocumentById(id); if (inCache != null) { freshen(inCache.getID()); inCache.setTouchedBy(tag, new Date()); return true; } } return false; } }
MemoryCache implements Cache<T> { @Override public boolean markTouched(DocumentID<T> id, String tag) { DatabaseDocument<T> inCache; synchronized (this) { inCache = getDocumentById(id); if (inCache != null) { freshen(inCache.getID()); inCache.setTouchedBy(tag, new Date()); return true; } } return false; } MemoryCache(); }
MemoryCache implements Cache<T> { @Override public boolean markTouched(DocumentID<T> id, String tag) { DatabaseDocument<T> inCache; synchronized (this) { inCache = getDocumentById(id); if (inCache != null) { freshen(inCache.getID()); inCache.setTouchedBy(tag, new Date()); return true; } } return false; } 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 boolean markTouched(DocumentID<T> id, String tag) { DatabaseDocument<T> inCache; synchronized (this) { inCache = getDocumentById(id); if (inCache != null) { freshen(inCache.getID()); inCache.setTouchedBy(tag, new Date()); return true; } } return false; } 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);  }