talis/persona-node-client — pull request #4 by robotrobot (2014-04-11 11:51:48+00:00)
Title: Added caching and tests for obtainToken

In order to progress the echo flush_webhook I need to generate a new token. I merged that last night.

But I might be flushing (and this creating new tokens) in quick succession. So I want to cache that token for a reasonable time so I can re-use it. Rather than do this in echo I have pushed that down to the persona client.

This caches the new token in redis for the halflife of the token expiry and instead of going to persona on subsequent requests for a new token, it re-supplies the cached token with an adjusted expires_in property.