2 added 26 characters in body
source | link

First, my first idea to use memcached was wrong, because if a user does not login for awhile all references to him or her are removed from the cache. In this situation to check whether the user belongs to a toplevel group all groups need to be checked. It may be not efficient.

Instead I propose to add a caching relational DB table. This table will contain for a given group the set of all its direct and indirect users.

So checking if a user belongs to a group becomes completely straightforward.

Adding new users to a group isand adding new subgroups are also easy.

A harder think is removal a user from a group. To do this, we can:

  1. get the set of all groups directly containing this user;

  2. calculate the set of all groups which directly or indirectly contain the first set;

  3. subtract this last set from the set of all groups which directly or indirectly contain this user;

  4. remove the user from each element of the last set.

Well, I have not yet decided how to behave when removing a group (rather than a user). Comments are welcome.

First, my first idea to use memcached was wrong, because if a user does not login for awhile all references to him or her are removed from the cache. In this situation to check whether the user belongs to a toplevel group all groups need to be checked. It may be not efficient.

Instead I propose to add a caching relational DB table. This table will contain for a given group the set of all its direct and indirect users.

So checking if a user belongs to a group becomes completely straightforward.

Adding new users to a group is also easy.

A harder think is removal a user from a group. To do this, we can:

  1. get the set of all groups directly containing this user;

  2. calculate the set of all groups which directly or indirectly contain the first set;

  3. subtract this last set from the set of all groups which directly or indirectly contain this user;

  4. remove the user from each element of the last set.

Well, I have not yet decided how to behave when removing a group (rather than a user). Comments are welcome.

First, my first idea to use memcached was wrong, because if a user does not login for awhile all references to him or her are removed from the cache. In this situation to check whether the user belongs to a toplevel group all groups need to be checked. It may be not efficient.

Instead I propose to add a caching relational DB table. This table will contain for a given group the set of all its direct and indirect users.

So checking if a user belongs to a group becomes completely straightforward.

Adding new users to a group and adding new subgroups are also easy.

A harder think is removal a user from a group. To do this, we can:

  1. get the set of all groups directly containing this user;

  2. calculate the set of all groups which directly or indirectly contain the first set;

  3. subtract this last set from the set of all groups which directly or indirectly contain this user;

  4. remove the user from each element of the last set.

Well, I have not yet decided how to behave when removing a group (rather than a user). Comments are welcome.

1
source | link

First, my first idea to use memcached was wrong, because if a user does not login for awhile all references to him or her are removed from the cache. In this situation to check whether the user belongs to a toplevel group all groups need to be checked. It may be not efficient.

Instead I propose to add a caching relational DB table. This table will contain for a given group the set of all its direct and indirect users.

So checking if a user belongs to a group becomes completely straightforward.

Adding new users to a group is also easy.

A harder think is removal a user from a group. To do this, we can:

  1. get the set of all groups directly containing this user;

  2. calculate the set of all groups which directly or indirectly contain the first set;

  3. subtract this last set from the set of all groups which directly or indirectly contain this user;

  4. remove the user from each element of the last set.

Well, I have not yet decided how to behave when removing a group (rather than a user). Comments are welcome.