Skip to content
This repository was archived by the owner on Apr 18, 2021. It is now read-only.

Get freshness read file - #20

Open
fellou89 wants to merge 2 commits into
nicolasazrak:masterfrom
fellou89:get_freshness_read_file
Open

Get freshness read file#20
fellou89 wants to merge 2 commits into
nicolasazrak:masterfrom
fellou89:get_freshness_read_file

Conversation

@fellou89

@fellou89 fellou89 commented Mar 6, 2018

Copy link
Copy Markdown

GetFreshness exported function to check if file has expired
Read function to get responses stored in cache

Alfredo Uribe added 2 commits January 19, 2018 12:33
to know if cache entry is new, found, or expired
@nicolasazrak

Copy link
Copy Markdown
Owner

@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.

@fellou89

fellou89 commented Mar 21, 2018

Copy link
Copy Markdown
Author

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.

@nicolasazrak

Copy link
Copy Markdown
Owner

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants