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