Redis ACL architecture

Viewed 496

I would like to use redis to check if users have permissions for certain places on a website.

The website allows users to create groups with limited features. There are essentially two types of users (potentially more) - Admins and Readers. One user can partake in different groups (10-15 groups)

First idea - create redis hashes for each user and include the groups that they are Admins for and the groups they are Readers. I can then control these by removing the records upon log out and setting the permissions upon login and change. Also the hash can expire.

Second idea - create hashes for each group and store the members that are admins and the members that are readers. This has the benefit that there will probably be less groups than members and I can pull the group's details too.

So my two questions are -

Which approach is better in terms of architecture?

Should I even be using Hashes (since I'll end up with something like group:1 admins [13,52,12,43] where the array holds the users ids or should I use something else where I can quickly pull the user id without having to parse the array and then loop through it every time?

1 Answers
Related