atmos/warden-github — pull request #28 by fphilipe (2013-02-07 14:27:55+00:00)
Title: Cache user memberships

This caches the membership statuses in the session user object.

When using memberships for authorization it makes sense to cache these values to prevent constantly repeated API calls.

The marshaled user object printed as YAML contains the memberships as follows:

```
warden.user.default.key: !ruby/struct:Warden::GitHub::User
attribs:
[...]
member:
org_pub:
rails: false
org:
rails: false
team:
345: true
[...]
token: […]
```

It definitely makes sense to expire the cached values. Not really sure how though :confused: Relying on the session to timeout probably isn't a good solution. How long do you think would it make sense to keep the cached values around? Would it make sense to expire all memberships at once or every individual one? I'd say that a couple hours (6 maybe?) is long enough and expiring all of them is good enough, too.