-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add thread-safe cache #84
Conversation
ffeaeb1
to
e3d95e9
Compare
Performance test extends CI test time too much. Will adjust it to run only once and not on each KV. |
e3d95e9
to
f8c9a88
Compare
Concurrency tests now only run on single vault and KV version to save time. |
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 looks like a great change I can refactor my pull around.
client/cache.go
Outdated
if value, ok := cache.listQueries[path]; ok { | ||
result = value.Secret | ||
err = value.Err | ||
hit = true |
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.
Can't ok
be used for this?
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.
Good catch 👍
Adjusted it now
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.
Sorry, apparently this doesn't work:
var hit bool
if value, hit := cache.listQueries[path]; hit {
result = value.Secret
err = value.Err
}
if hit {
// this branch is never reached
return result, err
}
Just now verified that it results in hit
always being false after leaving the first if scope. I am not really sure why though
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 the assignment is considered in the scope of the if
because of the :=
? These little Golang things catch me out too. :)
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.
Now this works :)
value, hit := cache.listQueries[path]
if hit {
return value.Secret, value.Err
}
I think this part ; ok {
binds the two initialized variables solely to the if scope.
5d0d973
to
c915bf9
Compare
c915bf9
to
8f55907
Compare
@mattlqx Concerning concurrency: |
Having a thread safe cache will make concurrency implementation easier.
Fixes #82