Skip to content

Add IIconCacheProvider abstraction with disk and in-memory implementa…#27

Open
degborta wants to merge 5 commits intomasterfrom
feature-inmemorycache
Open

Add IIconCacheProvider abstraction with disk and in-memory implementa…#27
degborta wants to merge 5 commits intomasterfrom
feature-inmemorycache

Conversation

@degborta
Copy link
Copy Markdown
Contributor

…tions

@degborta degborta added the enhancement New feature or request label Mar 24, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 IIconCacheProvider interface, developers can easily switch between a default disk-based cache, an in-memory cache, or implement their own custom caching strategies. This change improves the system's adaptability, allowing for better performance tuning and integration with various application architectures without altering core logic.

Highlights

  • Caching Abstraction: Introduced the IIconCacheProvider interface to abstract the logic for storing and retrieving generated content type icons, allowing for flexible caching strategies.
  • Default and In-Memory Implementations: Provided DiskIconCacheProvider as the default implementation, maintaining existing disk-based caching, and added InMemoryIconCacheProvider for caching icons in application memory.
  • Extensibility: Enabled developers to implement custom caching solutions by providing an extension method SetCacheProvider<T> to easily register their own IIconCacheProvider implementations.
  • Refactored Icon Service: Updated ContentTypeIconService to depend on and utilize the new IIconCacheProvider for all icon caching operations, removing direct file system interactions from the service.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment thread sandbox/Alloy/AlloyMvcTemplates.csproj Outdated
Comment thread sandbox/Alloy/Startup.cs Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 IIconCacheProvider plus DiskIconCacheProvider (default) and InMemoryIconCacheProvider.
  • Updated ContentTypeIconService to 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.

Comment thread src/Geta.Optimizely.ContentTypeIcons/Caching/IIconCacheProvider.cs
degborta and others added 3 commits March 25, 2026 14:44
…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.
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants