Skip to content
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

Default LRU policy could take last access time into account #18614

Closed
sertugkaya opened this issue Apr 29, 2021 · 1 comment
Closed

Default LRU policy could take last access time into account #18614

sertugkaya opened this issue Apr 29, 2021 · 1 comment
Assignees
Labels
Milestone

Comments

@sertugkaya
Copy link
Contributor

sertugkaya commented Apr 29, 2021

When triggered; LRU can clean up recently put but not yet touched entries.
While this can be remediated with a custom eviction policy such as below, it is discussed and agreed upon that we can provide this ootb.

Per engineering feedback this can be included in the upcoming platform release as well as backporting to 4.x.
ZD 7222

public class FixedLRUPolicyComparator extends LRUEvictionPolicyComparator {
    @Override
    public int compare(EvictableEntryView e1, EvictableEntryView e2) {

        long accessTime1 = e1.getLastAccessTime();
        long accessTime2 = e2.getLastAccessTime();

        if( accessTime1 == 0 && accessTime2 == 0) {
            return 0;
        }

        if(accessTime1 == 0) {
            return 1;
        }

        if(accessTime2 == 0) {
            return -1;
        }

        return super.compare(e1, e2);
    }
}
@ahmetmircik
Copy link
Member

closed by #18624

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants