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

[feature] item_size function #20

Open
FreakTheMighty opened this issue Feb 24, 2021 · 0 comments
Open

[feature] item_size function #20

FreakTheMighty opened this issue Feb 24, 2021 · 0 comments

Comments

@FreakTheMighty
Copy link

Overview

When determining how large the cache using max_size is it may be useful to treat some items as larger than other to provide a better proxy for their memory footprint. For example, I have a function that caches 3D meshes. Setting a max_size to a fixed number doesn't capture the fact that some 3D meshes are very large while others are very small.

Proposal

Similar to the custom_key_maker, a developer could provide an item_size function that returns an integer allowing them to calculate the size of cached items based on the cache entry. In the use-case described above, I might return a value based on the number of vertexes in my mesh.

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

1 participant