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

Adding maxsize in the decorator #429

Closed
Maxyme opened this issue Dec 16, 2018 · 7 comments
Closed

Adding maxsize in the decorator #429

Maxyme opened this issue Dec 16, 2018 · 7 comments
Labels

Comments

@Maxyme
Copy link

Maxyme commented Dec 16, 2018

lru_tools (and alru_tools) support a maxsize option in the decorator:
@alru_cache(maxsize=32)

Seeing that a pr was merged with the notion of max_keys per cache: #17, how hard would it be to implement a maxsize argument for the decorator?

I can see this being useful to have a simple way to prevent the in-memory cache from getting too big.

@kornicameister
Copy link

I have personally developed two simple plugins specifically for that, there weren't there hard to cook up. Perhaps that is the reason why that's not done by default :). But I am new to this library, still testing it so it's hard for me to judge.

@argaen
Copy link
Member

argaen commented Dec 18, 2018

@Maxyme that's a very old PR and removed that feature because I was adding it initially for all backends but this only makes sense for memory one as redis and memcached control this in the backend side.

Perhaps that is the reason why that's not done by default :)

@kornicameister you're right. Its not hard to do this with a plugin but I think it would make sense to add this behavior in the memory backend as a feature. I'll leave this ticket open to implement that. Contributions ofc are always welcome :)

@argaen argaen added the feature label Dec 18, 2018
@kornicameister
Copy link

I can't promise that I will do it, there is a lot of work and family stuff going on already (especially before Christmas).

@Olegt0rr
Copy link

Any updates?
It's a very handy feature

@kornicameister
Copy link

I am trying to look into that, but for some reason neovim crashes on this repository. Like seriously, no idea what's wrong ;P. I will try to fix that or use another editor but that;s strange.

PS. Should this be available only for SimpleMemoryCache ?

@argaen
Copy link
Member

argaen commented Oct 15, 2020

Hey @kornicameister yes, Redis and Memcached have other mechanisms like memory limit, lru policies, etc. for controlling the behavior, doing this from client side doesn't make sense as you could have multiple workers working against the same Redis/Memcached. So yes, only for SimpleMemoryCache

@argaen argaen added this to the 0.12.0 milestone Oct 15, 2020
@argaen
Copy link
Member

argaen commented Oct 15, 2020

Closing in favor of more recent #498

@argaen argaen closed this as completed Oct 15, 2020
@argaen argaen removed this from the 0.12.0 milestone Oct 15, 2020
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

4 participants