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 do we need to configure both lifeWindow and cleanWindow? #376

Open
Mavis2103 opened this issue Sep 25, 2023 · 2 comments
Open

Why do we need to configure both lifeWindow and cleanWindow? #376

Mavis2103 opened this issue Sep 25, 2023 · 2 comments

Comments

@Mavis2103
Copy link

Mavis2103 commented Sep 25, 2023

I have a few questions:

  1. If I only set cleanWindow (not lifeWindow) what happens to the cache? Can the cache be cleaned?
  2. Is it possible to set lifeWindow specifically for a cache created with its key? Because lifeWindow and cleanWindow are both configured in config if applied to all keys, I find lifeWindow and cleanWindow not very meaningful, instead just need 1 parameter like TTL
  3. The lifeWindow of a cache has its time reset when accessing that cache again while the lifeWindow is still valid. If not, what is the meaning of lifeWindow (similar to the question in question 2, it only needs 1 parameter)
  4. As I see it, if lifeWindow and cleanWindow are set to 10 seconds, the clear time will be the 20th second. My wish is the 10th second. So, I have to set lifeWindow < cleanWindow. I still don't understand the meaning of lifeWindow existence when it could be as simple as just 1 parameter like TTL
  5. If I use Delete("key"), will the cache be deleted?
    I hope to have an answer soon. Thanks for your support.
@janisz
Copy link
Collaborator

janisz commented Oct 12, 2023

  1. Good point. That could be a bug. As there is no way to not set config entry you can only set it to 0 that will cause every entry be marked as expired. Maybe we should add a check for this and return error when life window is 0 and clean window not.

https://github.com/allegro/bigcache/blob/main/shard.go#L289

  1. Nope, life window is per all entries [Feature Request] Expiration or TTL for each key individually #231
  2. I'm sorry I don't get this question. Could you rephrase it?
  3. ditto
  4. Nope, or not immediately. It will be marked as deleted and then replaced with new entry when it will be added.

@coxley
Copy link

coxley commented Oct 20, 2023

@Mavis2103: The motivation for having expiring and eviction as two separate processes in caches is to spend a deterministic amount of time locking the entries. Sharding is further used to help this, which bigcache also does.

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

3 participants