-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Feature request: TTL cache #1751
Comments
We've been talking about improving http.send to cache across queries. I just realized we did not have an issue filed to track that. This issues is related to it. Ref #1753 |
A syntax I'm thinking of implementing in a plugin; open to comments.
|
hey @krotscheck, here are some thoughts. Implementing this kind of caching as a set of built-in function ( If myval = v {
response := http.send({
"method": "get",
"https://example.com",
"ttl": "5m"})
v := response.body.some_value
} If a more general-purpose caching mechanism is required (e.g., perhaps there's some compute-intensive operation happening on the result of cache myval = 5*60 # "cache the value of myval for no more than 5 minutes"
myval = v {
# do expensive thing to get 'v'
} Do you think the first approach would work for your use cases? |
I think that'd work - as long as the cache can (also?/optionally?) be somehow keyed to the input. For instance, if I use a JWT as an input, it's unlikely that the policy response - no matter how expensive its calculation is - will change for the lifetime of the JWT. Any suggestions on that? |
Yes, this would be up to the built-in function. We actually have some built-in functions whose outputs are cached for the duration of the top-level policy query (e.g., If the |
Now that |
Wanted feature
TTL cache for OPA(The only thing I see as missing to make OPA fully conform to ABAC(PIP)).
I was thinking in the line of:
A possible implementation could be to use DATA(and non-updatable by put calls) as the Cache with a mere Json structured map, where a thread in the background is handling TTL's and deletion.
And ofcourse the above is only enabled through, e.g., opa run -s --cache-enabled --cache-ttl=3600(in seconds) or something like that.
Use-case
A rest-service handles a lot of customers, each customer is divided into sub-users stationed in various locations. Each of these sub-divisioned client needs fine-grained access-control due to different payment plans for different data from the rest-service. All the scalable data(attributes) at a point is several GBs in size and can't be stored in memory, so OPA uses instead a TTL cache for attributes needed aligned with each specific JWT attribute needed. If the cache doesn't have the attributes needed, OPA issues a http.send to the external resource and stores the response in cache aligned with the JWT attribute used. Now OPA fully supports the ABAC paradigm.
The text was updated successfully, but these errors were encountered: