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

[rest] Add caching for TagResource & De-duplicate code for caching #3729

Merged
merged 4 commits into from
Jul 25, 2023

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Jul 24, 2023

This implements caching for GET /rest/tags and GET /rest/tags/:tagname as in #3335 and de-duplicates RegistryChangeListener code used by nearly all cached REST resources by introducing the RegistryChangedRunnableListener class.

@florian-h05 florian-h05 marked this pull request as ready for review July 24, 2023 15:51
@florian-h05 florian-h05 requested a review from a team as a code owner July 24, 2023 15:51
@spacemanspiff2007
Copy link
Contributor

Would it be also possible to emit a change event or is this out of scope?
For HABApp the parameter is useless but an event would make caching possible.

@florian-h05
Copy link
Contributor Author

From my POV it's out of scope of this PR, in general it's up to the core maintainers to decide whether to merge such a PR, just ask them.

@J-N-K
Copy link
Member

J-N-K commented Jul 24, 2023

Regarding this PR: Fine with me, however I would prefer to have the RegistryChangedResetListener more generic (i.e. a ProviderChangeListener<T> that accepts a Runnable in the constructor) so that we can simply call new RegistryChangedResetListener(this::resetLastChanged) instead of duplicating the same code again and again. Do you feel that you can do that? Otherwise I'll merge this now and put that on my list.

Regarding the event: I don't think there is a good argument against having an event for "tags changed". If someone provides a PR for that, I would be willing to review and merge. I guess the event type needs to be defined and the registry needs to be enhanced so that it gets a reference to the EventPublisher.

This new class allows to add execute a Runnable on any type of change to the registry

Signed-off-by: Florian Hotze <[email protected]>
@florian-h05
Copy link
Contributor Author

Do you feel that you can do that?

Finished! I created a RegistryChangedRunnableListener that executes a passed in Runnable on any type of registry changes and used this for Item, rule & Thing resources as well. The UI resource is using different code, I therefore didn't change it.

@florian-h05 florian-h05 changed the title [rest] Add caching for TagResource [rest] Add caching for TagResource & De-duplicate code for caching Jul 24, 2023
@J-N-K J-N-K added enhancement An enhancement or new feature of the Core REST/SSE labels Jul 25, 2023
@florian-h05 florian-h05 requested a review from J-N-K July 25, 2023 18:20
Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@J-N-K J-N-K added this to the 4.1 milestone Jul 25, 2023
@J-N-K J-N-K merged commit e1741cf into openhab:main Jul 25, 2023
2 checks passed
@florian-h05 florian-h05 deleted the rest-caching branch July 25, 2023 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core REST/SSE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants