Skip to content

Commit

Permalink
Merge pull request #2935 from cflxl/niyiming-dev
Browse files Browse the repository at this point in the history
solve the unremoved result in keyList
  • Loading branch information
hazendaz committed Sep 8, 2023
2 parents 0fd8233 + 2cabe73 commit fdbd5e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -64,6 +64,7 @@ public Object getObject(Object key) {

@Override
public Object removeObject(Object key) {
keyList.remove(key);
return delegate.removeObject(key);
}

Expand Down
12 changes: 12 additions & 0 deletions src/test/java/org/apache/ibatis/cache/FifoCacheTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,16 @@ void shouldFlushAllItemsOnDemand() {
assertNull(cache.getObject(4));
}

@Test
void shouldRiseConflictInBeyondFiveEntries() {
FifoCache cache = new FifoCache(new PerpetualCache("default"));
cache.setSize(5);
for (int i = 0; i < 5; i++) {
cache.putObject(i, i);
}
cache.removeObject(1);
cache.putObject(1, 1);
assertNotNull(cache.getObject(0));
}

}

0 comments on commit fdbd5e5

Please sign in to comment.