feat: Add collection caching for improved performance - #63
Open
mattkduran wants to merge 3 commits into
Open
Conversation
- Added _tubeArchivistCollectionId field to cache collection GUID on startup - Added CacheTubeArchivistCollectionId() to find and cache collection once - Added RefreshTubeArchivistCollectionId() to update cache on config changes - Added IsItemInTubeArchivistCollection() helper for efficient validation - Updated PluginConfiguration.CollectionTitle to trigger cache refresh on change - Updated OnPlaybackProgress to use cached ID for O(1) validation This eliminates repeated database lookups (3 per playback event) by caching the collection ID once at startup. For libraries with thousands of movies, this significantly reduces overhead when non-TubeArchivist media is played. Performance improvement: - Before: 3 calls per playback event for all media types - After: 0 calls for rejected media (type check), 1-3 for Episodes only
4 tasks
When configuration is saved, Jellyfin creates a new configuration object, so we need to pass the new collection title directly to the refresh method instead of reading from the Configuration property which may still hold the old value during the setter execution. Changes: - Pass collectionTitle parameter to RefreshTubeArchivistCollectionId() - Update CacheTubeArchivistCollectionId() to accept optional title parameter - Prevents searching for stale collection name when config changes
This was referenced Oct 18, 2025
Closed
Collaborator
|
Could you please align with the latest modifications? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The current implementation performs 3 database lookups (
GetItemById) for every playback event to validate if content belongs to the TubeArchivist collection. This creates unnecessary overhead, especially when playing non-TubeArchivist content like movies or music.Solution
Cache the TubeArchivist collection GUID once at startup and use it for O(1) validation checks.
Changes
Added collection ID caching:
_tubeArchivistCollectionIdfield stores the cached GUIDCacheTubeArchivistCollectionId()finds and caches the collection on startupDynamic cache updates:
RefreshTubeArchivistCollectionId()public method to refresh the cachePluginConfiguration.CollectionTitlesetter to trigger refresh on changesEfficient validation:
IsItemInTubeArchivistCollection()helper methodPerformance Impact
Before:
After:
Testing