• Alex Vandiver's avatar
    Cache Attributes on the CurrentUser object, not an ephemeral User object · 5b707dfe
    Alex Vandiver authored
    The previous commit moved preferences to using the Attributes cache;
    however, this gains little because the cache is on the User object
    derived from the CurrentUser, which is derived afresh each time that
    RT->Config->Get() is called.
    Call the ->Preferences method directly on the CurrentUser, instead of
    the desrived User, so the cache is on the more durable CurrentUser
    object.  The cache is cleared (via ->ClearAttributes) during the ->Load
    call at the start of every request.  ->DeletePreferences is also
    switched to use ->DeleteAttribute, which explicitly purges the cache;
    otherwise, it may return stale data.
    This better attribute caching ensures that even negative preferences
    loads are cached for the duration of the request.  This, in turn,
    eliminates a large number of repeated database queries (such as for the
    username format preference) for users with no explicit preferences set.
Config.pm 45.4 KB