mozilla / id.webmaker.org

OAuth 2.0 identity provider for Webmaker
https://id.webmaker.org
Mozilla Public License 2.0
19 stars 51 forks source link

Login caching #368

Closed cadecairos closed 9 years ago

cadecairos commented 9 years ago

Fixes #367

Two commits here:

The first commit refactors the "account.js" file into a Hapi module that exposes its methods as Hapi server methods (this makes adding caching where we want it much easier) The methods don't change, only how they're called and required into the server.

The second commit adds in the caching to getUser, cached for 24 hours, stale in one, with a staleTimeout of 100ms (return cached value if refresh takes any longer). If there's an error or no user is returned, the result is not cached by passing "0" into the callback as the third argument.

jbuck commented 9 years ago

@cadecairos this looks pretty good! I made some notes around cache timing and making the developer experience better

jbuck commented 9 years ago

@cadecairos r+