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

why not have a map to storage the eternal item? #30

Open
icaiyu opened this issue May 28, 2019 · 2 comments
Open

why not have a map to storage the eternal item? #30

icaiyu opened this issue May 28, 2019 · 2 comments

Comments

@icaiyu
Copy link

icaiyu commented May 28, 2019

Establish a map to storage the eternal items so that ExpirationCheck don't have to check them in the iteration ? why not?

@muesli
Copy link
Owner

muesli commented May 30, 2019

Can you elaborate a bit more what you're suggesting?

@icaiyu
Copy link
Author

icaiyu commented May 30, 2019

Every expirationCheck will iterate all items including the permanent items and and non-permanent items. I think it unnecessary to check the permanent items, why not store them to another map so that the expirationCheck checks the non-permanent items only.

Plus..
I think that using cleanupInterval to check the expiration is not that efficient.
Like this example:
Add an item with lifespan = 10 to a blank table, the cleanupInterval will be 10s,
6s later, add another item with lifespan = 8, it will call the table.expirationcheck()
because item.lifespan < cleanupInteval
in fact, it's unnecessary to check because 10 - 6 < 8 (the cleanupTimer countdown to 10-6 = 4) .
In a nutshell, the cleanupTimer is really close to call expirationCheck as time goes by, however, the cleanupInterval remains unchanged!

Since we couldn't get the countdown time of the cleanupTimer directly, note down the cleaning time as cleanupTime is helpful to make it.

I submit a PR. If I was wrong please correct me and I will be really grateful. Thank you in advance!

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

No branches or pull requests

2 participants