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

client: Cache raw field information #1798

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

client: Cache raw field information #1798

wants to merge 2 commits into from

Conversation

lhh
Copy link

@lhh lhh commented Jan 12, 2024

The field JSON from the JIRA server contains important information, such as schemas, which can be used by applications building on this library. Since it's generally preferred, whenever possible, to reduce unnecessary calls to JIRA API endpoints, we can keep this information in the client object.

@lhh
Copy link
Author

lhh commented Jan 12, 2024

There doesn't seem to be a way for me apply the label after submitting the PR, but this would fall under 'enhancement'.

@lhh
Copy link
Author

lhh commented Jan 12, 2024

The py38 failure seems to be unrelated to the change here.

@lhh lhh closed this Jan 12, 2024
@lhh lhh reopened this Jan 12, 2024
lhh added a commit to lhh/jirate that referenced this pull request Jan 19, 2024
In order to avoid calling /field more than once per
session, override the field() call.  This is related
to (and arguably obviates):

pycontribs/jira#1798
@adehad
Copy link
Collaborator

adehad commented Mar 22, 2024

Have you considered the possibility for using a functools.lru_cache decorator on the method?
That would also give us some helper methods, like the ability to clear the cache

(as you say the cloud test failings are unrelated, so no need to worry)

The field JSON from the JIRA server contains important
information, such as schemas, which can be used by
applications building on this library. Since it's generally
preferred, whenever possible, to reduce unnecessary calls to
JIRA API endpoints, we can keep this information in the
client object.
@lhh
Copy link
Author

lhh commented Apr 11, 2024

It would be possible to do that.

The rate of change of the information in /rest/api/latest/field is not typically very fast, but it is certainly true that the information does get updated, and that re-fetching it periodically is a good idea in long-running processes.

Presently, the value in _fields_cache_value is not done that way - once it is populated, it is not updated from the JIRA server. This MR follows that precedent.

If we do decide use functools.lru_cache decorator with _fields_cache_value_raw, I think we need to be careful to ensure that the value in _field_cache_value is updated whenever the value of _fields_cache_value_raw is updated; these data sets should be consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants