Skip to content

VictronClient.system.cache, optimize (reduce) cache size, avoid format differences compared to dbus-spy #302

@Chris927

Description

@Chris927

Observations

We probably cache more than necessary.

On the other hand, we do not cache the text responses of GetValue calls, which would be useful to avoid the differences between dbus-spy responses and the response to HTTP GET /victron/cache, compare this comment.

Example to explain the differences between dbus-spy and GET /victron/cache responses, using the property AvailableTemperatureServices of com.victronenergy.system:

  1. dbus-spy responds with a nicely readable text representation:
$ dbus -y com.victronenergy.system /AvailableTemperatureServices GetValue
{'default': 'Automatic', 'nosensor': 'No sensor'}
  1. When calling GET /victron/cache, we get the actual value response of GetValue stringified (basically JSON.stringify() applied to the dbus value:
$ curl --silent --insecure https://venus.local:1881/victron/cache | jq '."com.victronenergy.system/0" ."/AvailableTemperatureServices"'
"[[\"default\",[[{\"type\":\"s\",\"child\":[]}],[\"Automatic\"]]],[\"nosensor\",[[{\"type\":\"s\",\"child\":[]}],[\"No sensor\"]]]]"
  1. Before the PR, we got the raw object (not stringified):
curl --silent --insecure https://venus.local:1881//victron/cache | jq '."com.victronenergy.system/0" ."/AvailableTemperatureServices"'
[
  [
    "default",
    [
      [
        {
          "type": "s",
          "child": []
        }
      ],
      [
        "Automatic"
      ]
    ]
  ],
  [
    "nosensor",
    [
      [
        {
          "type": "s",
          "child": []
        }
      ],
      [
        "No sensor"
      ]
    ]
  ]
]

Expectations

  1. We should cache only what we need, to minimize main memory utilization. As we are not able to track who or what uses the HTTP endpoint GET /victron/cache, it is risky to just remove or change (parts of) the cache.

  2. The response format differences are confusing, and may lead to bugs, so we should align our responses to /victron/cache with the responses to dbus-spy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions