swissmanu / harmonyhubjs-client

A Node.JS library which allows you to interact with your Logitech Harmony Hub.
https://github.com/swissmanu/harmonyhubjs-client
MIT License
155 stars 42 forks source link

Add a cache for "config" #39

Closed jhansche closed 5 years ago

jhansche commented 6 years ago

Because getAvailableCommands() is used as the basis for many other actions, and the payload is so gigantic, plus the fact that it does not change very frequently, it makes sense to keep that response cached.

The only way this would become out of sync is if you make changes to the harmony setup (activities and devices).

To improve on this, it might make sense to see if we can detect when the hub needs a sync, and invalidate the cache then. Or we can add a cache expiration time.

For most clients, the cache isn't needed. This is only useful for a client that keeps the connection open for a long time -- like a REST web service that dispatches commands to Harmony.

swissmanu commented 5 years ago

thank you for your contribution and sorry for my very late reply. would you please have a look at the failed build and my review? i am happy to integrate your changes afterwards.

swissmanu commented 5 years ago

awesome @jhansche! going to release it right now :) thanks for your contribution!