Closed souleb closed 1 month ago
Thanks for working on this, @souleb!
The store interface is a simplified version of client go store.
It would be handy to have a link in the code. At the moment this is only mentioned in a commit message and PR description.
What may need to be made more explicit is that the sore is persisted to a file.
Thanks for working on this, @souleb!
The store interface is a simplified version of client go store.
It would be handy to have a link in the code. At the moment this is only mentioned in a commit message and PR description.
What may need to be made more explicit is that the sore is persisted to a file.
There is a comment in store.go
pointing to https://pkg.go.dev/k8s.io/client-go/tools/cache#Store.
Persisting to a file will be made in a follow up PR where we will outline the use case we have for it.
Exciting to see this merged! 🌟
This PR will allow caching the authentication credentials retrieved by
pkg/oci/auth
. It should also enable future usage of the caching underlying mechanism.Part of: #642
Store design
The store is K/V store that can store arbitrary objects. The store interface is a simplified version of client go store. If an object can be cached there, it should be in our store implementations. This is desirable, because the primary envisioned place for the store usage is during a reconciliation of custom resources retrieved from a shared informer cache.
The
keys
are generated dynamically with deterministic function. Accepting a function instead ofkey strings
enables user to determine themselves the keys uniqueness constraint.They store must be thread safe, it should support concurrent programs.
There are 2 main uses cases:
Store
interface and underlying implementation should allow replacinghttps://github.com/fluxcd/source-controller/tree/main/internal/cache
which is today used to cachehelm indexes
. Ahelm index
is written, read and overwritten multiple times by multiple goroutines. Usually an index is stored and read multiple times (reconciliation of all dependent custom resources * interval) before being overwritten by a new version. It is read intensive. An index is read from local storage before being cached, if the cache is full, we could have several Custom Resources loading the same index in memory, in order to avoid that, we should evict older keys to make room.Based on the two scenario above, the store should be optimized for
reads
.We also have a scenario that needs
keys
to expirable and another that need them be evicted based on usage.Hence two implementations are provided: