You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lazy loading and caching for attributes set in _loadData(..) (#1510)
* feat: Implemented a caching mecahnism for PlexObject classes
- Cached properties are defined using a `cached_data_property` decorator
- Property caches are automatically invalidated whenever the `_data` atribute is changed
- The implementation uses a metaclass to collect and track all cached properties across class inheritances
* perf: Cache all data attributes that are computation heavy
These attributes include those that call `findItems` and `listAttrs`
* fix: Don't invalidate property cache on object initialization
* refactor: For all Plex objects, call the base class's loadData function to do cache invalidation
* perf: Convert attributes that call `findItem` to cached data properties
* perf: Attempt to parse XML strings without cleaning (which is expensive) before trying again with cleaning
* Revert "perf: Attempt to parse XML strings without cleaning (which is expensive) before trying again with cleaning"
This reverts commit e8348df.
* fix: Use the correct attribute name when deleting invalidated cached data
* fix: Follow the same behavior as before the introduction of cached properties and don't call the super class' _loadData
* fix: Typo in declaring cached data property attributes
* test: Don't use ` __dict__` to access attributes
* test: Don't reload objects for the test_video_Movie_reload_kwargs test
* fix: Ensure `PlexObject._loadData` is called in child classes that override loadData
* fix: Handle special cache invalidation for LibrarySection objects
* test: Tests for cache invalidation in library and video objects
* test: Removed unexpected exception from test_library_section_cache_invalidation
* test: Replaced incorrect object ID comparisons with string string repr comparisons
* refactor: Removed uneeded variable assignment
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
* perf: Convert languageCodes and mediaTypes to lazy-loaded cached properties
* refactor: Delegate cache invalidation logic to the reload function instead of _loadData
* style: Removed unecessary explicit object inheritence (implicit since Python3)
* perf: Lazy load expensive attributes in PlexSession
* docs: Make it clearer that Playable, PlexSession, and PlexHistory are mixins
* fix: Handle special reload cache invalidation logic for MyPlexAccount and PlexClient
* refactor: Unused import
* style: Reorder functions for more accurate order of operation
* docs: Removed typo
* refactor: Fixed all flake8 unused import warning
* fix: Invalidate the cache after all PUT queries in the PlayQueue object
* refactor: Call loadData with invalidation in the Settings class for future compatability
* refactor: Better align the items and reload functions with the internal caching mechanism
* fix: Reset the state of Hub pagination metadata on reloads
* docs: Updated docstring for `Hub.reload(...)` changes
---------
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>
0 commit comments