Skip to content

st.cache expiration (#1152)#100

Merged
sthagen merged 1 commit intosthagen:developfrom
streamlit:develop
Mar 3, 2020
Merged

st.cache expiration (#1152)#100
sthagen merged 1 commit intosthagen:developfrom
streamlit:develop

Conversation

@sthagen
Copy link
Copy Markdown
Owner

@sthagen sthagen commented Mar 3, 2020

Adds ttl and max_entries params to @st.cache

  • Each @st.cached function now has its own in-memory cache (previously, all functions shared a single cache).
  • cachetools.LRUCache and cachetools.TTLCache replace raw dictionaries as the cache implementations.

This closes #364. (Well, partly: per discussions with @tvst and @treuille, the other bits of that ticket (global and finalizer_func options) are going to wait for more discussion about caching changes.)

Before contributing (PLEASE READ!)

⚠️ As with most projects, prior to starting to code on a bug fix or feature request, please post in the issue saying you want to volunteer, and then wait for a positive response. And if there is no issue for it yet, create it first.

This helps make sure (1) two people aren't working on the same thing, (2) this is something Streamlit's maintainers believe should be implemented/fixed, (3) any API, UI, or deeper architectural changes that need to be implemented have been fully thought through by Streamlit's maintainers.

More information in our wiki: https://github.com/streamlit/streamlit/wiki/Contributing


Issue: Please include a link to the issue you're addressing. If no issue exists, create one first and then link it here.

Description: Describe the changes you made to the code, so it's easier for the reader to navigate your pull request. Usually this is a bullet list.


Contribution License Agreement

By submiting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

Adds `ttl` and `max_entries` params to `@st.cache`

- Each `@st.cache`d function now has its own in-memory cache (previously, all functions shared a single cache).
- `cachetools.LRUCache` and `cachetools.TTLCache` replace raw dictionaries as the cache implementations.

This closes #364. (Well, partly: per discussions with @tvst and @treuille, the other bits of that ticket (`global` and `finalizer_func` options) are going to wait for more discussion about caching changes.)
@sthagen sthagen merged commit 73f6ac1 into sthagen:develop Mar 3, 2020
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

Successfully merging this pull request may close these issues.

Better control of cached object lifecycles

2 participants