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

Change the L2 maxSize behavior to evict idle entries #515

Open
nekhtan opened this issue Jun 28, 2024 · 1 comment
Open

Change the L2 maxSize behavior to evict idle entries #515

nekhtan opened this issue Jun 28, 2024 · 1 comment

Comments

@nekhtan
Copy link

nekhtan commented Jun 28, 2024

Hello,

It seems that the datanucleus.cache.level2.maxsize feature is only preventing the cache from storing more objects once it reaches the defined limit. Would that be possible to change this behavior so that it starts evicting idle entries when the threshold is near (or even reached if it's easier to do) ?

Also, looking at the AbstractReferencedLevel2Cache, since the putAll method does not implement the maxSize feature and the put method checks for equality, isn't it possible that even the implemented feature (on the put) is broken because the threshold is exceeded following a call to putAll ?

Example:

  • maxSize=10
  • put(1) -> ok - size = 1
  • put(1) -> ok - size = 2
  • putAll(10) -> ok - size = 12
  • put(1) -> ok -> should have been rejected, right ?

Thanks in advance for your insight !

@nekhtan nekhtan changed the title maxSize isn't working as expected Change the maxSize behavior to evict idle entries Jun 28, 2024
@nekhtan nekhtan changed the title Change the maxSize behavior to evict idle entries Change the L2 maxSize behavior to evict idle entries Jun 28, 2024
@andyjefferson
Copy link
Member

Thanks for your comments. You are welcome to contribute a proposed improvement to the handling, via a pull request.
Yes, the current maxSize handling is simple; it provides a reference for people to improve upon for their specific situation. When we have a better implementation that can become the default.

I don't see anything broken in the current implementation on the face of it. putAll(10) in your example will try to put each of the 10 new objects one by one and will be successful with the first 8 until size() reaches 10. The last 2 will be rejected.

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

No branches or pull requests

2 participants