Skip to content

Cache Eviction not working #1369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
the-wrangler17 opened this issue Mar 15, 2022 · 1 comment · Fixed by #1371 or #1373
Closed

Cache Eviction not working #1369

the-wrangler17 opened this issue Mar 15, 2022 · 1 comment · Fixed by #1371 or #1373
Assignees
Labels
type: bug A general bug

Comments

@the-wrangler17
Copy link

Cache eviction is not taking into account the scope and collection, only the bucket. The problem seems to be in the DefaultCouchbaseCacheWriter.clear(String) method.

public long clear(final String pattern) {
QueryResult result = clientFactory.getCluster().query(
"DELETE FROM " + clientFactory.getBucket().name() + " where meta().id LIKE $pattern",
queryOptions().metrics(true).parameters(JsonObject.create().put("pattern", pattern + "%")));
return result.metaData().metrics().map(QueryMetrics::mutationCount).orElse(0L);
}

@mikereiche mikereiche added the type: bug A general bug label Mar 16, 2022
@mikereiche mikereiche self-assigned this Mar 16, 2022
@mikereiche
Copy link
Collaborator

the cacheEvict test case does not check that user1 is evicted. Only that user2 is not evicted.

@Test
void cacheEvict() {
	CacheUser user1 = new CacheUser(UUID.randomUUID().toString(), "first1", "last1");
	CacheUser user2 = new CacheUser(UUID.randomUUID().toString(), "first2", "last2");
	cache.put(user1.getId(), user1); // put user1
	cache.put(user2.getId(), user2); // put user2
	cache.evict(user1.getId()); // evict user1
	assertEquals(user2, cache.get(user2.getId()).get()); // get user2 -> present
}

mikereiche added a commit that referenced this issue Mar 16, 2022
mikereiche added a commit that referenced this issue Mar 16, 2022
mikereiche added a commit that referenced this issue Mar 16, 2022
mikereiche added a commit that referenced this issue Mar 16, 2022
mikereiche added a commit that referenced this issue Mar 16, 2022
mikereiche added a commit that referenced this issue Mar 16, 2022
mikereiche added a commit that referenced this issue Mar 16, 2022
mikereiche added a commit that referenced this issue Mar 16, 2022
mikereiche added a commit that referenced this issue Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
2 participants