Skip to content

Add local cache #30

Description

@lvps

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions