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

WIP: Implementing TTL for cached datasource instances #1230

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iwysiu
Copy link
Contributor

@iwysiu iwysiu commented Feb 12, 2025

What this PR does / why we need it:
Investigation for implementing caching for datasource instances. It's pretty simple and straightforward. I did this using a popular caching library that we already use in core grafana.

There are a couple minor implementation notes/questions:

  • The linked issue mentions expiring after a certain amount of inactivity, this automatically expires instances after a set amount of time. I decided to do this because tracking the activity would require us to take a write lock every time we get an instance so that we could update it and would require us to write our own janitor processes.
  • Both the InstanceManager consumers in this repo generate string keys, but updating the interface to expect one is technically a breaking change, so I didn't make it. We could make a new InstanceManagerWithExpiration type if we wanted to avoid the sprintf
  • Would we want this behavior behind a feature flag?
  • The chosen expiration timeouts were arbitrary, we could make them settable, but I don't think we need that.

Which issue(s) this PR fixes:

Fixes https://github.com/grafana/data-sources/issues/329

Special notes for your reviewer:

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.

1 participant