[PR #63] feat: Add collection caching for improved performance #76

Open
opened 2026-03-23 20:35:40 +00:00 by mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/tubearchivist/tubearchivist-jf-plugin/pull/63
Author: @mattkduran
Created: 10/17/2025
Status: 🔄 Open

Base: masterHead: feat/collection-caching


📝 Commits (3)

  • c0bafbb feat: Add collection caching for improved performance
  • 0377810 fix: Ensure collection cache uses correct value on config change
  • b05ae0c refactor: Rename JFTASync to JFTAProgressSync for consistency in configuration

📊 Changes

4 files changed (+282 additions, -51 deletions)

View changed files

📝 Jellyfin.Plugin.TubeArchivistMetadata/Configuration/PluginConfiguration.cs (+24 -4)
📝 Jellyfin.Plugin.TubeArchivistMetadata/Configuration/configPage.html (+5 -5)
📝 Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs (+252 -41)
📝 Jellyfin.Plugin.TubeArchivistMetadata/Tasks/JFToTubeArchivistProgressSyncTask.cs (+1 -1)

📄 Description

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

  1. Added collection ID caching:

    • _tubeArchivistCollectionId field stores the cached GUID
    • CacheTubeArchivistCollectionId() finds and caches the collection on startup
  2. Dynamic cache updates:

    • RefreshTubeArchivistCollectionId() public method to refresh the cache
    • Updated PluginConfiguration.CollectionTitle setter to trigger refresh on changes
    • No restart required when changing collection name
  3. Efficient validation:

    • IsItemInTubeArchivistCollection() helper method
    • Walks parent hierarchy comparing cached GUID (fast)
    • Falls back to name-based lookup if cache is not initialized

Performance Impact

Before:

  • 3 calls per playback event for ALL media
  • Example: Playing 100 movies = 300 lookups

After:

  • 1 call on startup (caching)
  • 0 calls for rejected media (type check + cached ID)
  • 1-3 calls only for TubeArchivist Episodes
  • Example: Playing 100 movies = 0 lookups, instant rejection

Testing

  • Startup: Collection cached successfully
  • Config change: Cache refreshes automatically
  • Movie playback: Fast rejection with cached ID
  • TubeArchivist video: Still validates and syncs correctly
  • Missing collection: Falls back to name-based validation

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/tubearchivist/tubearchivist-jf-plugin/pull/63 **Author:** [@mattkduran](https://github.com/mattkduran) **Created:** 10/17/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `feat/collection-caching` --- ### 📝 Commits (3) - [`c0bafbb`](https://github.com/tubearchivist/tubearchivist-jf-plugin/commit/c0bafbb1da2d04d59580afa80fe1a221bc78ad22) feat: Add collection caching for improved performance - [`0377810`](https://github.com/tubearchivist/tubearchivist-jf-plugin/commit/0377810bd803db48af77e6efeea256411fe3ca2b) fix: Ensure collection cache uses correct value on config change - [`b05ae0c`](https://github.com/tubearchivist/tubearchivist-jf-plugin/commit/b05ae0c6c3dfbb44c233f854fc53f06e9c00a692) refactor: Rename JFTASync to JFTAProgressSync for consistency in configuration ### 📊 Changes **4 files changed** (+282 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `Jellyfin.Plugin.TubeArchivistMetadata/Configuration/PluginConfiguration.cs` (+24 -4) 📝 `Jellyfin.Plugin.TubeArchivistMetadata/Configuration/configPage.html` (+5 -5) 📝 `Jellyfin.Plugin.TubeArchivistMetadata/Plugin.cs` (+252 -41) 📝 `Jellyfin.Plugin.TubeArchivistMetadata/Tasks/JFToTubeArchivistProgressSyncTask.cs` (+1 -1) </details> ### 📄 Description ## 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 1. **Added collection ID caching**: - `_tubeArchivistCollectionId` field stores the cached GUID - `CacheTubeArchivistCollectionId()` finds and caches the collection on startup 2. **Dynamic cache updates**: - `RefreshTubeArchivistCollectionId()` public method to refresh the cache - Updated `PluginConfiguration.CollectionTitle` setter to trigger refresh on changes - No restart required when changing collection name 3. **Efficient validation**: - `IsItemInTubeArchivistCollection()` helper method - Walks parent hierarchy comparing cached GUID (fast) - Falls back to name-based lookup if cache is not initialized ## Performance Impact **Before:** - 3 calls per playback event for ALL media - Example: Playing 100 movies = 300 lookups **After:** - 1 call on startup (caching) - 0 calls for rejected media (type check + cached ID) - 1-3 calls only for TubeArchivist Episodes - Example: Playing 100 movies = 0 lookups, instant rejection ## Testing - Startup: Collection cached successfully - Config change: Cache refreshes automatically - Movie playback: Fast rejection with cached ID - TubeArchivist video: Still validates and syncs correctly - Missing collection: Falls back to name-based validation --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tubearchivist/archived-tubearchivist-jf-plugin#76
No description provided.