Currently, usernames are always looked up in LDAP directory, except for:
- users pass the
--no-ldap parameter, or
- the standard and normalized username is passed during logout (since it is found in the log files)
This is sub-optimal and does too many queries. Before performing the search, we should look up the username (or matricola, or alias) in a cache. In case of an hit, use that result.
If the cache misses but the result is found with a LDAP search, add it to the cache.
If the LDAP search fails, do not add anything to the cache.
The cache should ideally be a dictionary, with username/matricola/alias as the key, and normalized username as the value (the uid attribute from LDAP). They may be equal: the cache still provides the information that it is a valid username. However each entry should also have a timestamp.
Entries should be invalidated and removed after a configurable amount of time, with a default of 24 hours. When accessing the cache, check all entries and remove expired ones.
The cache should be stored in ~/.cache/something as a JSON or pickled file or anything else that can be serialized and deserialized easily. The file should be created if it does not exist.
Currently, usernames are always looked up in LDAP directory, except for:
--no-ldapparameter, orThis is sub-optimal and does too many queries. Before performing the search, we should look up the username (or matricola, or alias) in a cache. In case of an hit, use that result.
If the cache misses but the result is found with a LDAP search, add it to the cache.
If the LDAP search fails, do not add anything to the cache.
The cache should ideally be a dictionary, with username/matricola/alias as the key, and normalized username as the value (the
uidattribute from LDAP). They may be equal: the cache still provides the information that it is a valid username. However each entry should also have a timestamp.Entries should be invalidated and removed after a configurable amount of time, with a default of 24 hours. When accessing the cache, check all entries and remove expired ones.
The cache should be stored in
~/.cache/somethingas a JSON or pickled file or anything else that can be serialized and deserialized easily. The file should be created if it does not exist.