Skip to content

Conversation

@lilfaf
Copy link
Contributor

@lilfaf lilfaf commented Dec 30, 2025

Replace per-manager embedded moka caches with a unified caching layer that uses the existing CacheManager (Memory/Redis/Redis Cluster).

CachedAppManager wraps any AppManager implementation, providing:

  • Dual-key indexing (app:id:{id} and app:key:{key})
  • Automatic cache invalidation on create/update/delete
  • Configurable via env var APP_MANAGER_CACHE_ENABLED and APP_MANAGER_CACHE_TTL

Changes:

  • Added cached_app_manager decorator
  • Remove embedded moka caches from MySQL, PostgreSQL, DynamoDB, ScyllaDB managers
  • Update factory.rs to wrap managers with caching layer
  • Reorder main.rs init so CacheManager is created before AppManager
  • Clean up verbose/redundant logging in app managers

It matches Soketi's caching strategy.

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Testing

  • Unit tests pass
  • Integration tests pass
  • Manual testing completed

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Build Artifacts

Additional Notes

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lilfaf, 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 refactors the application caching strategy by introducing a unified, decorator-based caching layer. It replaces disparate in-memory caches embedded within various database-specific AppManager implementations with a centralized CachedAppManager. This change aims to standardize caching behavior, improve configurability, and leverage a shared CacheManager (which can be Memory, Redis, or Redis Cluster) for more consistent and efficient cache management across the application.

Highlights

  • Unified App Caching Layer: A new CachedAppManager decorator has been introduced to provide a centralized caching layer for all AppManager implementations. This decorator supports dual-key indexing (by app ID and app key), automatic cache invalidation on create, update, and delete operations, and is configurable via environment variables APP_MANAGER_CACHE_ENABLED and APP_MANAGER_CACHE_TTL.
  • Removal of Embedded Caches: The individual moka caches previously embedded within MySQLAppManager, PgSQLAppManager, DynamoDbAppManager, and ScyllaDbAppManager have been removed. This centralizes the caching logic and configuration to the new CachedAppManager.
  • AppManagerFactory Integration: The AppManagerFactory has been updated to conditionally wrap the underlying AppManager implementations with the new CachedAppManager if caching is enabled in the configuration. This ensures that all app managers can benefit from the unified caching.
  • Initialization Order Adjustment: The server initialization sequence in main.rs has been reordered to ensure that the CacheManager is created and available before the AppManager, as the CachedAppManager now depends on an initialized CacheManager instance.
  • Logging Refinement: Verbose and redundant logging statements within the various app managers have been cleaned up to improve clarity and reduce log noise.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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
Contributor

@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 centralized caching layer for the AppManager using a decorator pattern, which is a significant architectural improvement. It successfully removes the scattered moka cache implementations from individual database managers, simplifying their code. The new CachedAppManager correctly handles cache-aside logic for reads and cache updates. I've identified a high-severity correctness bug in the update_app logic that could lead to stale cache entries, along with a couple of medium-severity suggestions to improve performance and logging. Overall, this is a solid refactoring that greatly improves the caching strategy.

Replace per-manager embedded moka caches with a unified caching layer that
uses the existing CacheManager (Memory/Redis/Redis Cluster).

CachedAppManager wraps any AppManager implementation, providing:
- Dual-key indexing (app:id:{id} and app:key:{key})
- Automatic cache invalidation on create/update/delete
- Configurable via env var APP_MANAGER_CACHE_ENABLED and APP_MANAGER_CACHE_TTL

Changes:
- Added cached_app_manager decorator
- Remove embedded moka caches from MySQL, PostgreSQL, DynamoDB, ScyllaDB managers
- Update factory.rs to wrap managers with caching layer
- Reorder main.rs init so CacheManager is created before AppManager
- Clean up verbose/redundant logging in app managers

It matches Soketi's caching strategy.
@lilfaf lilfaf force-pushed the cached-app-manager branch from f59665b to 31b82cf Compare December 30, 2025 22:49
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