Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add local cache #30

Open
lvps opened this issue Dec 1, 2019 · 0 comments
Open

Add local cache #30

lvps opened this issue Dec 1, 2019 · 0 comments

Comments

@lvps
Copy link
Member

lvps commented Dec 1, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant