Add IIconCacheProvider abstraction with disk and in-memory implementa…#27
Add IIconCacheProvider abstraction with disk and in-memory implementa…#27
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the icon caching mechanism by introducing a flexible abstraction layer. Previously, icon caching was hardcoded to disk storage. Now, with the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a valuable abstraction IIconCacheProvider for caching generated icons, along with default implementations for disk and in-memory caching. This significantly improves the flexibility of the caching mechanism, allowing consumers to choose a caching strategy or implement their own. The refactoring to move cache-specific logic into the providers is well-executed. I've found a couple of minor issues in the sandbox project that should be addressed.
There was a problem hiding this comment.
Pull request overview
Introduces an IIconCacheProvider abstraction to decouple thumbnail icon caching from the ContentTypeIconService, enabling both disk-based and in-memory caching implementations and allowing consumers to swap providers via DI.
Changes:
- Added
IIconCacheProviderplusDiskIconCacheProvider(default) andInMemoryIconCacheProvider. - Updated
ContentTypeIconServiceto use the cache provider instead of directly writing/reading cached PNGs from disk. - Added DI registration and a
SetCacheProvider<T>()extension method; updated startup/init flow, docs, and sandbox usage.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Geta.Optimizely.ContentTypeIcons.Tests/ThumbnailIconControllerFixture.cs | Updates test wiring to pass a cache provider into ContentTypeIconService. |
| src/Geta.Optimizely.ContentTypeIcons/Infrastructure/Initialization/ApplicationBuilderExtensions.cs | Switches startup initialization from “ensure folder exists” to IIconCacheProvider.Initialize(). |
| src/Geta.Optimizely.ContentTypeIcons/Infrastructure/Configuration/ServiceCollectionExtensions.cs | Registers default cache provider and adds SetCacheProvider<T>() for provider replacement. |
| src/Geta.Optimizely.ContentTypeIcons/ContentTypeIconService.cs | Replaces direct file IO caching with cache-provider calls. |
| src/Geta.Optimizely.ContentTypeIcons/Caching/InMemoryIconCacheProvider.cs | New in-memory cache provider implementation. |
| src/Geta.Optimizely.ContentTypeIcons/Caching/IIconCacheProvider.cs | New cache provider abstraction. |
| src/Geta.Optimizely.ContentTypeIcons/Caching/DiskIconCacheProvider.cs | New disk-based cache provider implementation (directory creation + PNG persistence). |
| sandbox/Alloy/Startup.cs | Demonstrates switching to InMemoryIconCacheProvider via SetCacheProvider<T>(). |
| sandbox/Alloy/Models/Pages/SearchPage.cs | Updates sandbox page to use ContentTypeIcon attribute example. |
| sandbox/Alloy/AlloyMvcTemplates.csproj | Adds sandbox folder and post-build copy target for plugin zip into modules folder. |
| README.md | Documents new caching model and how to use/customize cache providers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…r.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… is used at runtime, apply sliding expiration to in-memory cache entries, and add tests for SetCacheProvider.
|



…tions