-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Proposal: Allow Setting Cache Miss Policy in Cache Options #2397
Comments
@alvaroaleman points out that Also, for type CacheMissPolicy string
const (
// Fail configures the cache to return a sentinel error when a user requests a resource
// the cache is not configured to hold. This error is distinct from an errors.NotFound
// and should be considered a programming error.
Fail CacheMissPolicy = "fail"
// Backfill configures the cache to spin up an informer for a resource when the first
// request for that resource comes in. This means that a Get or a List may take longer
// than normal to succeed on the first invocation as the cache waits until it's fully back-
// filled.
Backfill CacheMissPolicy = "backfill"
) Perhaps |
Just realizing that the better proposal would be that the |
Which error? |
Maybe we could have a |
I'm proposing:
This sounds like what you mean by |
So the flows for a
|
@vincepri @alvaroaleman do you think this is fleshed-out enough for me to attempt an implementation? Any other feedback? |
Yeah I'm generally +1 |
Yeah, sgtm
That is a good idea, but in the interest of not having too much magic, maybe make it opt-in? |
Today, when a user gets a
client.Client
from aManager
(withmgr.GetClient()
), they get a cache-backed client that has some surprising behavior - when a cache miss occurs, an informer is spun up to feed data into the cache. This means that oneclient.Get()
call for one resource will, by default, start a cluster-scoped watch on all objects of that type and keep them in memory forever. While this is an understandable way for the cache to work, I've seen it bite folks who did not expect this behavior. While I don't think that this should be the default, at a minimum I'd love to see the cache miss policy be configurable at creation time so that folks can opt out of this behavior. Today it is possible to opt out of caching particular resources, but that's done with a hard-coded deny-list, which means if you ever forget to update that list, you get bitten.I'd like to propose adding a new field in the
cache.Options
:We can keep the default as
"backfill"
to not change behavior./cc @alvaroaleman @vincepri
The text was updated successfully, but these errors were encountered: