Open foltik opened 2 years ago
We can benefit from the terraform behaviour that reads are done before doing any changes. So we only need to cache the first read. Create and updates could use uncached calls as these are way less frequent.
Now i recall that another reson for caching at low level was that we had multiple variations of showtree, show and showany. With these merged we can implement a cachedShowTree to be used by the provider reads only. We could also do it so that any call to the uncached would refresh the cache in case we want later to use the caches putside reads.
Let me know if you want me to help with any of the coding I can wait as I am using my fork for now but I enjoy contributing to this project and hope others at k8s-at-home start leveraging Vyos with Terraform.
From https://github.com/Foltik/vyos-client-go/pull/4:
One simple way to address this would be to add a config cache to
ProviderClass
with some wrapper Set and Get methods that handle populating and invalidating the cache.Until we have a better testing story, it might be better to have a coarser invalidation strategy (e.g. full invalidate on every Set) to avoid the complexity and potential opportunities for bugs in trying to merge config objects and do partial invalidation or local updates.