Commit 0d4124f
Lazy loading and caching for attributes set in
* 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>_loadData(..) (#1510)1 parent 80edff1 commit 0d4124f
17 files changed
Lines changed: 651 additions & 225 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
66 | 65 | | |
67 | | - | |
68 | 66 | | |
69 | | - | |
70 | 67 | | |
71 | 68 | | |
72 | 69 | | |
| |||
75 | 72 | | |
76 | 73 | | |
77 | 74 | | |
78 | | - | |
79 | 75 | | |
80 | 76 | | |
81 | 77 | | |
| |||
88 | 84 | | |
89 | 85 | | |
90 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
91 | 99 | | |
92 | 100 | | |
93 | 101 | | |
| |||
205 | 213 | | |
206 | 214 | | |
207 | 215 | | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | 216 | | |
213 | | - | |
214 | | - | |
215 | 217 | | |
216 | | - | |
217 | | - | |
218 | 218 | | |
219 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
220 | 255 | | |
221 | 256 | | |
222 | 257 | | |
| |||
355 | 390 | | |
356 | 391 | | |
357 | 392 | | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | 393 | | |
363 | | - | |
364 | 394 | | |
365 | 395 | | |
366 | 396 | | |
| |||
372 | 402 | | |
373 | 403 | | |
374 | 404 | | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | 405 | | |
379 | 406 | | |
380 | 407 | | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
381 | 440 | | |
382 | 441 | | |
383 | 442 | | |
| |||
495 | 554 | | |
496 | 555 | | |
497 | 556 | | |
498 | | - | |
499 | 557 | | |
500 | | - | |
501 | 558 | | |
502 | | - | |
503 | 559 | | |
504 | 560 | | |
505 | 561 | | |
506 | 562 | | |
507 | 563 | | |
508 | 564 | | |
509 | 565 | | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | 566 | | |
514 | 567 | | |
515 | 568 | | |
| |||
525 | 578 | | |
526 | 579 | | |
527 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
528 | 605 | | |
529 | 606 | | |
530 | 607 | | |
| |||
0 commit comments