Open fellou89 opened 6 years ago
@fellou89 Thanks for your PR but I think I don't understand the porpoise of this change:
In the cache.go
why would you want to differentiate weather the bucket where the response is stored exists or not? The buckets are an optimization to reduce the lock contention, so it's only and internal implementation detail.
In the response.go
why do you add the Read
method? It seems it's not used anywhere.
I'm working on an authentication module that validates a client access token and a refresh access token. It needs to cache the authenticated identity that comes back from the auth endpoint. That's where the Read
method is used, getting the identity response stored in the cache.
I added the freshness check to cut some time out of the auth process. If an access token cache entry is no longer fresh (has gone past the configured max-age), then I want to return a 401 immediately, without having to incur the additional time it takes to validate the (expired) token on the auth endpoint.
I don't think this is a good change, it doesn't add a new feature to the plugin nor it fixes a bug. You can develop your plugin without this changes. Instead of using the read
method you can use the one from the storage. And with the status of the entry, you always use response == nil
.
GetFreshness exported function to check if file has expired Read function to get responses stored in cache