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

[Blockly] Modify the Value Storage blocks to use the new sharedCache and privateCache #1577

Closed
rkoshak opened this issue Dec 12, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@rkoshak
Copy link

rkoshak commented Dec 12, 2022

Which UI are you reporting an issue for?

Blockly

The problem

The current implementation relies on the fact that a script is reused after it's first created. Objects and variables cannot be shared between scripts and data is not cleaned up when scripts are unloaded.

Your suggestion

With the introduction of sharedCache and privateCache there is now a way integrated into core to preserve variables between runs of a rule (privateCache) and to share Objects and values between rules (sharedCache). These have the advantage that they get cleaned up when the rules are unloaded (no more stale timers going off when a rule is reloaded) and we have cross script sharing. It should even work across scripts written in different languages.

If just the privateCache is implemented (limited to that one script), the existing blocks could probably be reused with only changes to the back end JavaScript being required. If sharedCache is added, a new set of similar blocks will be needed, or an option added to the existing blocks to choose which cache is being used.

Your environment

runtimeInfo:
  version: 3.4.0
  buildString: "Build #3210"
locale: en-US
systemInfo:
  configFolder: /openhab/conf
  userdataFolder: /openhab/userdata
  logFolder: /openhab/userdata/logs
  javaVersion: 11.0.17
  javaVendor: Eclipse Adoptium
  javaVendorVersion: Temurin-11.0.17+8
  osName: Linux
  osVersion: 5.15.0-56-generic
  osArchitecture: amd64
  availableProcessors: 4
  freeMemory: 68422648
  totalMemory: 614465536
  startLevel: 100
bindings:
  - amazonechocontrol
  - astro
  - chromecast
  - http
  - ipcamera
  - mail
  - mqtt
  - network
  - networkupstools
  - openweathermap
  - roku
  - shelly
  - zigbee
  - zwave
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: true
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: macos
    pixelRatio: 2
    prefersColorScheme: light
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 12
    language: en-US
    languages:
      - en-US
    onLine: true
    platform: MacIntel
  screen:
    width: 1920
    height: 1080
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: filled
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
    (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
timestamp: 2022-12-12T20:21:21.450Z

Additional information

@rkoshak rkoshak added the enhancement New feature or request label Dec 12, 2022
@ghys
Copy link
Member

ghys commented Dec 13, 2022

If just the privateCache is implemented (limited to that one script), the existing blocks could probably be reused with only changes to the back end JavaScript being required.

If this is implemented (and throughly tested) during the feature freeze I'll consider it as a "fix" :)

@florian-h05
Copy link
Contributor

@rkoshak
I am currently implementing this in #1597 (I have just finished the ValueCache Blocks today) for JS Scripting.
I don’t see much sense in implementing this for Nashorn, since we are not so far away from having all blocks ported to JS Scripting (Blockly will be able to generate code both for Nashorn and Graal when Stefan and I are finished).

I decided to use the private cache for the ValueCache in JS Scripting Blockly, but after Stefan and I are finished with the portation of Blockly and this is merged, we can of course tweak Blockly to also allow access to the shared cache. We only have to make sure that we do not break existing Blockly scripts.

@rkoshak
Copy link
Author

rkoshak commented Dec 22, 2022

I figured this would probably best fit in with that work. There was no way I was going to be able to get to this before the 3.4 release and I agree, now it doesn't make a whole lot of sense to back port it to Nashorn.

@florian-h05
Copy link
Contributor

I have added a link to this as a reminder to the „big“ issue for the Blockly porting.

@stefan-hoehn
Copy link
Contributor

stefan-hoehn commented Dec 22, 2022

How do you like that, @rkoshak ?

image

These blocks will only appear when you have jsscripting installed. Otherwise they stay as they are without the choice to select the cache.

@stefan-hoehn
Copy link
Contributor

This will be fixed with #1597 and is already implemented there. You might want to close it here.

@rkoshak
Copy link
Author

rkoshak commented Dec 28, 2022

Fixed by #1597

@rkoshak rkoshak closed this as completed Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants