Skip to content

Add album-queries caching - #4602

Merged
ildyria merged 13 commits into
masterfrom
caching-enablement
Aug 14, 2026
Merged

Add album-queries caching#4602
ildyria merged 13 commits into
masterfrom
caching-enablement

Conversation

@ildyria

@ildyria ildyria commented Aug 9, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features
    • Added configurable caching for album listings, including browsing, child pagination, tag albums, person albums, pinned albums, and root listings.
    • Added session-aware caching for unlocked album visibility and configurable cache expiration.
    • Added targeted cache updates for user membership changes.
  • Bug Fixes
    • Album listings now refresh correctly after edits, moves, sharing changes, tag updates, deletions, cover changes, and configuration updates.
  • Tests
    • Expanded coverage for caching, invalidation, album updates, sharing, tags, and membership changes.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 94f4c560-29c4-47dd-b0ae-0586c02963e7

📥 Commits

Reviewing files that changed from the base of the PR and between 106395c and b76fc3e.

📒 Files selected for processing (1)
  • tests/Feature_v2/Tags/GetTagsTest.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Feature_v2/Tags/GetTagsTest.php

📝 Walkthrough

Walkthrough

Album-listing caching now covers paginated children, root listings, tag listings, person listings, pinned listings, and tag-detail albums. New events and listeners invalidate cached data after album, tag, permission, membership, configuration, tree, photo, and computed-data changes.

Changes

Album Listing Caching

Layer / File(s) Summary
Cache contracts and service behavior
app/Services/Cache/CacheKeyProvider.php, app/Services/Cache/ManagedCacheService.php, config/features.php, database/migrations/..., app/Events/*
Added cache keys, cache tags, conditional caching, batch invalidation, TTL defaults, album-cache configuration, and batched lifecycle event payloads.
Cached album queries and invalidation
app/Repositories/AlbumRepository.php, app/Actions/Albums/Top.php, app/Actions/Tag/GetTagWithPhotosAndAlbums.php, app/Listeners/*, app/Providers/EventServiceProvider.php
Added managed caching for paginated children, independent top-level listings, and unlock-session-aware tag albums. Registered targeted and coarse cache invalidation handlers.
Mutation event wiring
app/Actions/*, app/Http/Controllers/*, app/Jobs/*, app/Console/Commands/*, app/DTO/*
Added saved, hierarchy, permission, tagging, membership, computed-data, and cache-flush dispatches across mutation paths.
Validation and specifications
tests/*, docs/specs/...
Added event, cache, invalidation, query-count, serialization, configuration, and session-isolation coverage. Updated Feature 053 specifications and implementation records.

Estimated code review effort: 5 (Critical) | ~120 minutes

Merge Risk: 🟠 High · up to b76fc

This change adds album-listing caching and changes invalidation behavior, but the current head can still serve stale or incorrectly visible listings when cache tags or album updates are processed in the wrong order; required cache settings may also be inaccessible. The PR is not merge-ready until these invalidation and configuration issues are corrected and the required verification is completed.

Poem

A rabbit checks the cache by moonlight,
Events mark each album change.
Tags and roots refresh their entries,
Unlock states remain in range.
Tests record the paths precisely.

🚥 Pre-merge checks | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 58.70% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.34831% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.10%. Comparing base (763d13b) to head (b76fc3e).
⚠️ Report is 3 commits behind head on master.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ildyria
ildyria marked this pull request as ready for review August 13, 2026 20:15
@ildyria
ildyria requested a review from a team as a code owner August 13, 2026 20:15

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 18

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
config/features.php (1)

266-277: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Correct the config key names in the comment block.

The comment names cache_enabled, cache_ttl, and cache_event_logging. The code reads managed_cache_enabled and managed_cache_ttl (app/Services/Cache/ManagedCacheService.php lines 59 and 63), and this PR adds managed_cache_albums_enabled (database/migrations/2026_08_09_000000_managed_cache_albums_config.php line 16). Operators who follow this comment will look for settings that do not exist.

📝 Proposed fix
 	 | When enabled, admins can configure Redis-backed caching from
-	 | the settings panel (cache_enabled, cache_ttl, cache_event_logging).
+	 | the settings panel (managed_cache_enabled, managed_cache_ttl,
+	 | managed_cache_albums_enabled).
 	 | Disabled by default — set ENABLE_CACHING=true to activate.
-	 | Note: caching is only active when cache_enabled is also set to 1 in
-	 | the database settings.
+	 | Note: caching is only active when managed_cache_enabled is also set
+	 | to 1 in the database settings.
docs/specs/4-architecture/features/053-album-listing-caching/plan.md (1)

257-262: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add the required Markdown footer to every changed documentation file.

Each file must end with an hr line and an italic Last updated line.

  • docs/specs/4-architecture/features/053-album-listing-caching/plan.md#L257-L262: append --- and *Last updated: [actual update date]*.
  • docs/specs/4-architecture/features/052-managed-cache-service/tasks.md#L35-L36: append --- and *Last updated: [actual update date]*.
  • docs/specs/4-architecture/features/053-album-listing-caching/spec.md#L353-L356: append --- and *Last updated: [actual update date]*.
    As per coding guidelines: **/*.md: At the bottom of documentation files, add an hr line followed by *Last updated: [date of the update]*.

Source: Coding guidelines

docs/specs/4-architecture/features/053-album-listing-caching/tasks.md (1)

165-172: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Synchronize the required documentation footers.

These Feature 053 documentation updates leave the required footer missing or stale.

  • docs/specs/4-architecture/features/053-album-listing-caching/tasks.md#L165-L172: append --- and *Last updated: [date of the update]* at EOF.
  • docs/specs/4-architecture/roadmap.md#L20-L20: update the footer at Line 127 to the current update date and Feature 053 context.
  • docs/specs/_current-session.md#L138-L157: append the required footer at EOF.

As per coding guidelines, “At the bottom of documentation files, add an hr line followed by *Last updated: [date of the update]*.”

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 41ff4441-58fe-474a-8d33-b7ba8f122ea6

📥 Commits

Reviewing files that changed from the base of the PR and between 763d13b and 96c1d25.

📒 Files selected for processing (91)
  • app/Actions/Admin/BulkEditAlbumsAction.php
  • app/Actions/Album/Create.php
  • app/Actions/Album/CreatePersonAlbum.php
  • app/Actions/Album/CreateTagAlbum.php
  • app/Actions/Album/Delete.php
  • app/Actions/Album/Merge.php
  • app/Actions/Album/Move.php
  • app/Actions/Album/SetProtectionPolicy.php
  • app/Actions/Album/Transfer.php
  • app/Actions/Albums/Top.php
  • app/Actions/Photo/MoveOrDuplicate.php
  • app/Actions/Tag/DeleteTag.php
  • app/Actions/Tag/GetTagWithPhotosAndAlbums.php
  • app/Actions/Tag/MergeTag.php
  • app/Console/Commands/FixTree.php
  • app/Console/Commands/RecomputeAlbumSizes.php
  • app/Console/Commands/RecomputeAlbumStats.php
  • app/DTO/Delete/PhotosToBeDeletedDTO.php
  • app/Events/AccessPermissionChanged.php
  • app/Events/AlbumChildrenChanged.php
  • app/Events/AlbumComputedDataUpdated.php
  • app/Events/AlbumListingCacheFlushRequested.php
  • app/Events/AlbumSaved.php
  • app/Events/AlbumTagsChanged.php
  • app/Events/BaseAlbumRemoved.php
  • app/Events/PersonAlbumSaved.php
  • app/Events/TagAlbumSaved.php
  • app/Events/UserGroupMembershipChanged.php
  • app/Http/Controllers/Admin/Maintenance/DestroyDismissedFaces.php
  • app/Http/Controllers/Admin/ModerationController.php
  • app/Http/Controllers/Admin/SettingsController.php
  • app/Http/Controllers/Admin/UserGroupsManagementController.php
  • app/Http/Controllers/AiVision/FaceController.php
  • app/Http/Controllers/Gallery/AlbumController.php
  • app/Http/Controllers/Gallery/SharingController.php
  • app/Jobs/ApplyNsfwAlbumSensitivityJob.php
  • app/Jobs/RecomputeAlbumSizeJob.php
  • app/Jobs/RecomputeAlbumStatsJob.php
  • app/Listeners/ManagedCacheAlbumListingInvalidator.php
  • app/Listeners/ManagedCacheUserListingInvalidator.php
  • app/Listeners/RecomputeAlbumSizeOnAlbumChange.php
  • app/Listeners/RecomputeAlbumStatsOnAlbumChange.php
  • app/Observers/PhotoObserver.php
  • app/Policies/AlbumPolicy.php
  • app/Providers/EventServiceProvider.php
  • app/Repositories/AlbumRepository.php
  • app/Services/Cache/CacheKeyProvider.php
  • app/Services/Cache/ManagedCacheService.php
  • config/features.php
  • database/migrations/2026_08_09_000000_managed_cache_albums_config.php
  • docs/specs/4-architecture/features/052-managed-cache-service/tasks.md
  • docs/specs/4-architecture/features/053-album-listing-caching/plan.md
  • docs/specs/4-architecture/features/053-album-listing-caching/spec.md
  • docs/specs/4-architecture/features/053-album-listing-caching/tasks.md
  • docs/specs/4-architecture/knowledge-map.md
  • docs/specs/4-architecture/open-questions.md
  • docs/specs/4-architecture/roadmap.md
  • docs/specs/_current-session.md
  • tests/AssistedVision/NsfwClassification/ApplyNsfwAlbumSensitivityJobTest.php
  • tests/Feature_v2/Album/AlbumMergeTest.php
  • tests/Feature_v2/Album/AlbumMoveTest.php
  • tests/Feature_v2/Album/AlbumRenameTest.php
  • tests/Feature_v2/Album/AlbumSetCoverTest.php
  • tests/Feature_v2/Album/AlbumSetHeaderTest.php
  • tests/Feature_v2/Album/AlbumSetPinnedTest.php
  • tests/Feature_v2/Album/AlbumTagPersonSavedEventTest.php
  • tests/Feature_v2/Album/AlbumTransferTest.php
  • tests/Feature_v2/Album/AlbumUpdateFocusTest.php
  • tests/Feature_v2/Album/AlbumUpdateTest.php
  • tests/Feature_v2/Album/SharingTest.php
  • tests/Feature_v2/Album/TagAlbumSetCoverTest.php
  • tests/Feature_v2/BulkAlbumEdit/PatchTest.php
  • tests/Feature_v2/Settings/GetAllSettingsTest.php
  • tests/Feature_v2/Settings/UpdateSettingsTest.php
  • tests/Feature_v2/Tags/DeleteTagsTest.php
  • tests/Feature_v2/Tags/GetTagsTest.php
  • tests/Feature_v2/Tags/MergeTagsTest.php
  • tests/Feature_v2/UserGroup/UserGroupsManagementTest.php
  • tests/ImageProcessing/Photo/PhotoDeleteTest.php
  • tests/Precomputing/CoverSelection/EventListenersTest.php
  • tests/Precomputing/CoverSelection/RecomputeAlbumStatsJobTest.php
  • tests/Precomputing/SizeComputations/RecomputeAlbumSizeJobTest.php
  • tests/Unit/Actions/Album/DeleteTest.php
  • tests/Unit/Actions/Album/SetProtectionPolicyTest.php
  • tests/Unit/Actions/Album/SetSmartProtectionPolicyTest.php
  • tests/Unit/Actions/Albums/TopTest.php
  • tests/Unit/Console/Commands/FixTreeTest.php
  • tests/Unit/Listeners/ManagedCacheAlbumListingInvalidatorTest.php
  • tests/Unit/Listeners/ManagedCacheUserListingInvalidatorTest.php
  • tests/Unit/Repositories/AlbumRepositoryTest.php
  • tests/Unit/Services/Cache/ManagedCacheServiceTest.php

Comment thread app/Actions/Albums/Top.php Outdated
Comment thread app/Actions/Tag/GetTagWithPhotosAndAlbums.php
Comment thread app/Console/Commands/RecomputeAlbumSizes.php
Comment thread app/Http/Controllers/Admin/SettingsController.php
Comment thread app/Jobs/ApplyNsfwAlbumSensitivityJob.php
Comment thread docs/specs/4-architecture/open-questions.md
Comment thread tests/AssistedVision/NsfwClassification/ApplyNsfwAlbumSensitivityJobTest.php Outdated
Comment thread tests/Feature_v2/Album/AlbumMergeTest.php
Comment thread tests/Feature_v2/Settings/GetAllSettingsTest.php

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fcce63cf-5fd5-4a18-a47c-20b41cc72b28

📥 Commits

Reviewing files that changed from the base of the PR and between dbc1769 and 106395c.

📒 Files selected for processing (10)
  • app/Actions/Albums/Top.php
  • app/Actions/Tag/GetTagWithPhotosAndAlbums.php
  • app/Repositories/AlbumRepository.php
  • app/Services/Cache/CacheKeyProvider.php
  • app/Services/Cache/ManagedCacheService.php
  • tests/AssistedVision/NsfwClassification/ApplyNsfwAlbumSensitivityJobTest.php
  • tests/Feature_v2/Settings/GetAllSettingsTest.php
  • tests/Unit/Listeners/ManagedCacheAlbumListingInvalidatorTest.php
  • tests/Unit/Listeners/ManagedCacheUserListingInvalidatorTest.php
  • tests/Unit/Services/Cache/ManagedCacheServiceTest.php
🚧 Files skipped from review as they are similar to previous changes (9)
  • tests/Feature_v2/Settings/GetAllSettingsTest.php
  • tests/Unit/Listeners/ManagedCacheUserListingInvalidatorTest.php
  • app/Repositories/AlbumRepository.php
  • tests/AssistedVision/NsfwClassification/ApplyNsfwAlbumSensitivityJobTest.php
  • app/Actions/Tag/GetTagWithPhotosAndAlbums.php
  • app/Actions/Albums/Top.php
  • app/Services/Cache/CacheKeyProvider.php
  • tests/Unit/Services/Cache/ManagedCacheServiceTest.php
  • tests/Unit/Listeners/ManagedCacheAlbumListingInvalidatorTest.php

Comment thread app/Services/Cache/ManagedCacheService.php
Comment thread app/Services/Cache/ManagedCacheService.php
@ildyria
ildyria merged commit 088244d into master Aug 14, 2026
50 checks passed
@ildyria
ildyria deleted the caching-enablement branch August 14, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant