Repository navigation
generalized function caching - #10975
Conversation
8213b87 to
b486dd7
Compare
02a0f22 to
05d9d15
Compare
|
Dropping my thoughts on DX, since we just discussed it live... Option 1: two pragmasOne pragma to disable, another to configure.
Option 2: one pragmaOne pragma to rule them all.
I like option 2 best, because you can't beat the simplicity of a single pragma called |
|
@shykes Yeah I agree having a single pragma is appealing and simple. Even for hypothetical cases like "cache per session and also with a ttl" you could still easily support something like EDIT: or I suppose just multiple // +cache=session
// +cache=1m |
|
@sipsma if we go with option 2 (one pragma), I'm OK with not allowing multiple (yes I know I was asking for the opposite just an hour ago :) But I didn't expect a single pragma to work so well) |
7cec42a to
a5bd03b
Compare
c888826 to
d82d3df
Compare
9fd8660 to
1956429
Compare
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
| return r | ||
| } | ||
|
|
||
| func (r Result[T]) WithSafeToPersistCache(safe bool) AnyResult { |
|
!!!!!!!!!!!!!! 🥳 |
A module function with no cache setting had its cached result expire after one week, and a declared time to live (TTL) could be at most one week. #10975 added that limit when the function cache was a table whose rows were only ever deleted once they expired. The engine now deletes cached results by size, so the limit only made such functions run again every week, and put a one-week expiry on the results they returned, including results shipped in engine images. A function with no cache setting now has no expiry: Dagger keeps its cached result until its inputs change or the engine needs the disk space. A declared TTL may be longer than one week. Signed-off-by: Erik Sipsma <[email protected]>
A module function with no cache setting had its cached result expire after one week, and a declared time to live (TTL) could be at most one week. #10975 added that limit when the function cache was a table whose rows were only ever deleted once they expired. The engine now deletes cached results by size, so the limit only made such functions run again every week, and put a one-week expiry on the results they returned, including results shipped in engine images. A function with no cache setting now has no expiry: Dagger keeps its cached result until its inputs change or the engine needs the disk space. A declared TTL may be longer than one week. Signed-off-by: Erik Sipsma <[email protected]>
Go example:
Python example:
Typescript:
Got the TTL to behave as an actual TTL now, it starts when the function starts executing.
Also persisted in sqlite, with periodic (every 10m) gc of expired TTL metadata.
Caveats for now:
sessionornever, it defaults to a TTL of 7 days. This is to make pruning logic as simple as possible. Something more intelligent would obviously be preferable but would take much longer and require much further progress on the new theseus caching system.If a function makes a
SetSecretcall (i.e. the "inline" api call, not using a provider) and includes the result in its return value, the result will never be persistently cached, no matter the function cache settings. Per-session cache will still apply (backwards compatible).Newly init'd modules will start with function caching by default.
Already init'd modules upgrading to the new engine (with
dagger develop) will have a setting automatically placed in dagger.jsondisableDefaultFunctionCaching: true. Once the author is ready to upgrade, they can remove that setting.TODO:
SetSecret(secret not reproducible, can't cache)SetSecretbehaviorFollowups: