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

[jsscripting] Added simple Shared Cache into scope #11693

Merged
merged 1 commit into from
Dec 11, 2021

Conversation

jpg0
Copy link
Contributor

@jpg0 jpg0 commented Dec 3, 2021

Add a very basic shared cache into the JS add-on to allow JS scripts to cache objects between runs and/or scripts.

Signed-off-by: Jonathan Gilbert jpg@trillica.com

@jpg0
Copy link
Contributor Author

jpg0 commented Dec 3, 2021

Can be used like this:

let counter = require("@runtime").sharedcache.getOrCreate("counter", () => ({"times":0}))

counter.times = counter.times + 1
 
Java.type('org.slf4j.LoggerFactory').getLogger('script.js.cachetest').warn("count: " + counter.times); 

Which will increment the counter each time the script is run.

@wborn wborn added the enhancement An enhancement or new feature for an existing add-on label Dec 5, 2021
@digitaldan
Copy link
Contributor

Should we also expose remove(Object key) ?

@jpg0
Copy link
Contributor Author

jpg0 commented Dec 5, 2021

Should we also expose remove(Object key) ?

Yes I think that's sensible.

@jpg0 jpg0 force-pushed the add-shared-cache branch from 3023468 to aad3c63 Compare December 5, 2021 19:03
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
@jpg0 jpg0 force-pushed the add-shared-cache branch from aad3c63 to c8caff1 Compare December 5, 2021 19:11
Copy link
Contributor

@digitaldan digitaldan left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

LGTM

@lolodomo lolodomo merged commit c1b10c8 into openhab:main Dec 11, 2021
@lolodomo lolodomo added this to the 3.2 milestone Dec 11, 2021
NickWaterton pushed a commit to NickWaterton/openhab-addons that referenced this pull request Dec 30, 2021
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
Signed-off-by: Nick Waterton <n.waterton@outlook.com>
mischmidt83 pushed a commit to mischmidt83/openhab-addons that referenced this pull request Jan 9, 2022
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
Signed-off-by: Michael Schmidt <mi.schmidt.83@gmail.com>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Jan 28, 2022
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
Signed-off-by: Jonathan Gilbert <jpg@trillica.com>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
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 for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants