-
Notifications
You must be signed in to change notification settings - Fork 24
Store meta state in memory #836
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
Conversation
Delegated targets should be loaded at target search time, so keep state in memory so we can use it as necessary. Signed-off-by: Appu Goundan <[email protected]>
} | ||
|
||
public void setRoot(Root root) throws IOException { | ||
// call storeTrustedRoot instead of generic storeMeta because it does doesn't extra work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..does doesn't..
} | ||
|
||
public Root getRoot() throws IOException { | ||
return findRoot().orElseThrow(() -> new IllegalStateException("No cached root to load")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you can provide a little more context here (in the exception message) as to why this would happen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you really only call "getRoot" if you know you should have a root cached somewhere. But I guess I can add context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess from the point of the view of the user, if this blows up, what most likely happened, how can they fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool
return Optional.ofNullable(root); | ||
} | ||
|
||
public void setTimestamp(Timestamp timestamp) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not tempted to factor out the set/find/get logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was tempted but it meant generifying some of the getters and setters. I can do that
@@ -78,6 +83,7 @@ public class Updater { | |||
this.localStore = localStore; | |||
this.metaFetcher = metaFetcher; | |||
this.targetFetcher = targetFetcher; | |||
this.trustedMeta = TrustedMeta.newTrustedMeta(localStore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since it's a read-through cache, could it be simpler to just invalidate it on update or something rather than having the updater have to know about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh like if the root updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah probably
Signed-off-by: Appu Goundan <[email protected]>
alright, reworked this whole thing |
|
||
/** | ||
* Generic method to store one of the {@link SignedTufMeta} resources in the local tuf store. | ||
* Generic method to store one of the {@link SignedTufMeta} resources in the local tuf store. Do | ||
* not use for Root role, use {@link #setRoot(Root)} instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if you do use it for Root?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then you don't get N.root persisted (this is functionality that was already in there). I've just formalized it.
sigstore-java/src/main/java/dev/sigstore/tuf/PassthroughCacheMetaStore.java
Outdated
Show resolved
Hide resolved
/** An in memory cache that will pass through to a provided local tuf store. */ | ||
public class PassthroughCacheMetaStore implements MetaReader, MetaStore { | ||
private final MetaStore localStore; | ||
private final Map<String, SignedTufMeta<? extends TufMeta>> cache; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Guava has a Cache you can pass a read-through function to 🤔. I'm way out of date though so don't hesitate to tell me to GTFO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's a bit heavyweight, has eviction and what not. This is not a space limited cache.
888afee
to
4c741ca
Compare
Signed-off-by: Appu Goundan <[email protected]>
4c741ca
to
33482eb
Compare
Delegated targets should be loaded at target search time, so keep state in memory so we can use it as necessary.
This PR doesn't does add delegated targets support, but this is part of the process.