Skip to content

refactor: read config values dynamically instead of caching in instance variables#2610

Merged
chunxiaozheng merged 3 commits intoLMCache:devfrom
maobaolong:updateConfSupport
Feb 24, 2026
Merged

refactor: read config values dynamically instead of caching in instance variables#2610
chunxiaozheng merged 3 commits intoLMCache:devfrom
maobaolong:updateConfSupport

Conversation

@maobaolong
Copy link
Copy Markdown
Collaborator

Remove cached instance variables for config values that should support dynamic configuration updates. Instead, read them directly from the config object at each usage site.

Configs changed to dynamic reading:

  • blocking_timeout_secs (remote_backend.py)
  • lookup_timeout_ms (lmcache_lookup_client.py, lmcache_async_lookup_client.py)
  • save_decode_cache (vllm_v1_adapter.py)
  • force_store_wait (cache_engine.py)
  • save_unfull_chunk (token_database.py)
  • hit_miss_ratio, chunk_size (hit_limit_lookup_client.py)
  • ping_timeout, get_blocking_failed_threshold, waiting_time_for_recovery (remote_backend_check.py)

What this PR does / why we need it:

Special notes for your reviewers:

If applicable:

  • this PR contains user facing changes - docs added
  • this PR contains unit tests

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @maobaolong, 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 refactors several components to eliminate the caching of configuration values in instance variables. Instead, these values are now retrieved directly from the central configuration object whenever they are needed. This change is crucial for enabling dynamic updates to configuration settings without requiring application restarts or reinitialization of components, thereby improving the system's flexibility and responsiveness to operational changes.

Highlights

  • Dynamic Configuration Reading: Removed cached instance variables for various configuration values across multiple modules, ensuring they are read dynamically from the configuration object at each usage site.
  • Enhanced Flexibility: Enabled support for dynamic configuration updates for critical settings such as blocking_timeout_secs, lookup_timeout_ms, save_decode_cache, force_store_wait, save_unfull_chunk, hit_miss_ratio, chunk_size, ping_timeout, get_blocking_failed_threshold, and waiting_time_for_recovery.
  • Code Simplification: Streamlined code by removing redundant instance variables that previously stored static configuration values, promoting a more consistent approach to configuration access.

🧠 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.

Changelog
  • lmcache/integration/vllm/vllm_v1_adapter.py
    • Removed _save_decode_cache instance variable.
    • Updated build_connector_meta to read save_decode_cache dynamically from self.config.
  • lmcache/v1/cache_engine.py
    • Removed force_store_wait instance variable.
    • Updated store and store_layer methods to read force_store_wait dynamically using self.config.get_extra_config_value.
  • lmcache/v1/health_monitor/checks/remote_backend_check.py
    • Removed ping_timeout, get_blocking_failed_threshold, and waiting_time_for_recovery instance variables.
    • Updated check method to dynamically retrieve waiting_time_for_recovery, get_blocking_failed_threshold, and ping_timeout from the backend config.
  • lmcache/v1/lookup_client/hit_limit_lookup_client.py
    • Removed hit_ratio_upper and chunk_size instance variables.
    • Updated lookup method to dynamically calculate hit_ratio_upper and retrieve chunk_size from self.config.
    • Stored the config object as an instance variable self.config.
  • lmcache/v1/lookup_client/lmcache_async_lookup_client.py
    • Removed timeout_ms instance variable.
    • Updated lookup_cache method to read lookup_timeout_ms dynamically from self.config.
    • Stored the config object as an instance variable self.config.
  • lmcache/v1/lookup_client/lmcache_lookup_client.py
    • Removed timeout_ms instance variable.
    • Updated socket options in __init__ and _recreate_socket to use self.config.lookup_timeout_ms directly.
  • lmcache/v1/storage_backend/remote_backend.py
    • Removed blocking_timeout_secs instance variable.
    • Updated get_blocking, batched_get_blocking, and async methods to read blocking_timeout_secs dynamically from self.config.
  • lmcache/v1/token_database.py
    • Removed save_unfull_chunk instance variable.
    • Updated _chunk_tokens method to read save_unfull_chunk dynamically from self.config.
    • Stored the config object as an instance variable self.config.
Activity
  • No specific activity (comments, reviews, or progress updates) was provided in the context.
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
Copy Markdown
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 refactors the code to read several configuration values dynamically from the config object instead of caching them as instance variables. This is a good change that allows for dynamic configuration updates. The implementation looks correct across all modified files, consistently replacing cached attributes with direct configuration access at the usage sites. I have one minor suggestion to improve maintainability by reducing code duplication in one of the files.

Comment thread lmcache/v1/health_monitor/checks/remote_backend_check.py Outdated
@maobaolong maobaolong added the full Run comprehensive tests on this PR label Feb 19, 2026
…ce variables

Remove cached instance variables for config values that should support
dynamic configuration updates. Instead, read them directly from the
config object at each usage site.

Configs changed to dynamic reading:
- blocking_timeout_secs (remote_backend.py)
- lookup_timeout_ms (lmcache_lookup_client.py, lmcache_async_lookup_client.py)
- save_decode_cache (vllm_v1_adapter.py)
- force_store_wait (cache_engine.py)
- save_unfull_chunk (token_database.py)
- hit_miss_ratio, chunk_size (hit_limit_lookup_client.py)
- ping_timeout, get_blocking_failed_threshold, waiting_time_for_recovery (remote_backend_check.py)

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: baoloongmao <baoloongmao@tencent.com>
@maobaolong
Copy link
Copy Markdown
Collaborator Author

@sammshen @chunxiaozheng Would you like to take a look at this PR? Thanks!

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Copy link
Copy Markdown
Contributor

@sammshen sammshen left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Collaborator

@chunxiaozheng chunxiaozheng left a comment

Choose a reason for hiding this comment

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

lgtm

@chunxiaozheng chunxiaozheng merged commit 3cbd2b7 into LMCache:dev Feb 24, 2026
39 of 46 checks passed
sammshen pushed a commit to sammshen/LMCache that referenced this pull request Mar 1, 2026
…ce variables (LMCache#2610)

* refactor: read config values dynamically instead of caching in instance variables

Remove cached instance variables for config values that should support
dynamic configuration updates. Instead, read them directly from the
config object at each usage site.

Configs changed to dynamic reading:
- blocking_timeout_secs (remote_backend.py)
- lookup_timeout_ms (lmcache_lookup_client.py, lmcache_async_lookup_client.py)
- save_decode_cache (vllm_v1_adapter.py)
- force_store_wait (cache_engine.py)
- save_unfull_chunk (token_database.py)
- hit_miss_ratio, chunk_size (hit_limit_lookup_client.py)
- ping_timeout, get_blocking_failed_threshold, waiting_time_for_recovery (remote_backend_check.py)

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Address gemini's comment

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Fix code quality issue

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
hlin99 pushed a commit to hlin99/LMCache that referenced this pull request Mar 2, 2026
…ce variables (LMCache#2610)

* refactor: read config values dynamically instead of caching in instance variables

Remove cached instance variables for config values that should support
dynamic configuration updates. Instead, read them directly from the
config object at each usage site.

Configs changed to dynamic reading:
- blocking_timeout_secs (remote_backend.py)
- lookup_timeout_ms (lmcache_lookup_client.py, lmcache_async_lookup_client.py)
- save_decode_cache (vllm_v1_adapter.py)
- force_store_wait (cache_engine.py)
- save_unfull_chunk (token_database.py)
- hit_miss_ratio, chunk_size (hit_limit_lookup_client.py)
- ping_timeout, get_blocking_failed_threshold, waiting_time_for_recovery (remote_backend_check.py)

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Address gemini's comment

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Fix code quality issue

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
mauryaavinash95 pushed a commit to mauryaavinash95/LMCache that referenced this pull request Mar 7, 2026
…ce variables (LMCache#2610)

* refactor: read config values dynamically instead of caching in instance variables

Remove cached instance variables for config values that should support
dynamic configuration updates. Instead, read them directly from the
config object at each usage site.

Configs changed to dynamic reading:
- blocking_timeout_secs (remote_backend.py)
- lookup_timeout_ms (lmcache_lookup_client.py, lmcache_async_lookup_client.py)
- save_decode_cache (vllm_v1_adapter.py)
- force_store_wait (cache_engine.py)
- save_unfull_chunk (token_database.py)
- hit_miss_ratio, chunk_size (hit_limit_lookup_client.py)
- ping_timeout, get_blocking_failed_threshold, waiting_time_for_recovery (remote_backend_check.py)

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Address gemini's comment

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Fix code quality issue

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
shaoxiawjc pushed a commit to shaoxiawjc/LMCache that referenced this pull request Mar 11, 2026
…ce variables (LMCache#2610)

* refactor: read config values dynamically instead of caching in instance variables

Remove cached instance variables for config values that should support
dynamic configuration updates. Instead, read them directly from the
config object at each usage site.

Configs changed to dynamic reading:
- blocking_timeout_secs (remote_backend.py)
- lookup_timeout_ms (lmcache_lookup_client.py, lmcache_async_lookup_client.py)
- save_decode_cache (vllm_v1_adapter.py)
- force_store_wait (cache_engine.py)
- save_unfull_chunk (token_database.py)
- hit_miss_ratio, chunk_size (hit_limit_lookup_client.py)
- ping_timeout, get_blocking_failed_threshold, waiting_time_for_recovery (remote_backend_check.py)

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Address gemini's comment

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Fix code quality issue

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: shaoxiawjc <wjc2800@163.com>
realAaronWu pushed a commit to realAaronWu/LMCache that referenced this pull request Mar 20, 2026
…ce variables (LMCache#2610)

* refactor: read config values dynamically instead of caching in instance variables

Remove cached instance variables for config values that should support
dynamic configuration updates. Instead, read them directly from the
config object at each usage site.

Configs changed to dynamic reading:
- blocking_timeout_secs (remote_backend.py)
- lookup_timeout_ms (lmcache_lookup_client.py, lmcache_async_lookup_client.py)
- save_decode_cache (vllm_v1_adapter.py)
- force_store_wait (cache_engine.py)
- save_unfull_chunk (token_database.py)
- hit_miss_ratio, chunk_size (hit_limit_lookup_client.py)
- ping_timeout, get_blocking_failed_threshold, waiting_time_for_recovery (remote_backend_check.py)

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Address gemini's comment

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

* Fix code quality issue

Signed-off-by: baoloongmao <baoloongmao@tencent.com>

---------

Signed-off-by: baoloongmao <baoloongmao@tencent.com>
Signed-off-by: Aaron Wu <aaron.wu@dell.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full Run comprehensive tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants