-
Notifications
You must be signed in to change notification settings - Fork 8
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
[ACL-263] Caching improvements #337
Conversation
@@ -182,12 +185,13 @@ public TrueLayerClientBuilder withHttpLogs(Consumer<String> logConsumer) { | |||
* @return the instance of the client builder used | |||
*/ | |||
public TrueLayerClientBuilder withCredentialsCaching() { | |||
this.credentialsCache = new SimpleCredentialsCache(Clock.systemUTC()); | |||
this.credentialsCache = new InMemoryCredentialsCache(Clock.systemUTC()); |
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.
As we anyway need a breaking change for the new cache interface (that aligns to what PHP and .NET libs do), I took the chance to rename this to be more explicit
return MessageFormat.format("{0}:{1}:{2}", CACHE_KEY_PREFIX, clientId, bytesToHex(md5InBytes)); | ||
} | ||
|
||
private static byte[] digest(byte[] input) { |
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.
Instead of using a numeric hashcode I'm using MD5. We don't really need this to be bullet-proof, so I think it's fine.
Optional<AccessToken> getToken(RequestScopes scopes); | ||
Optional<AccessToken> getToken(String key); |
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.
This is the main change: users of a custom cache won't have to bother computing hash keys. They will receive what the client builds, and they have the option to customise/override those if needed
Description
This PR includes 2 necessary breaking changes:
Type of change
Please select multiple options if required.
Checklist:
gradle.properties
file with the new versionCHANGELOG.md
file with the details of the new version