Implementation:LMCache LMCache SGLang Utils
| Knowledge Sources | |
|---|---|
| Domains | Integration, Configuration |
| Last Updated | 2026-02-09 00:00 GMT |
Overview
Utility functions for the SGLang integration layer, providing configuration loading and boolean string parsing.
Description
This module contains helper functions used by LMCache's SGLang integration. The is_false function checks whether a string value represents a falsy boolean (supporting "false", "0", "no", "n", "off"). The lmcache_get_config function reads the LMCache engine configuration either from a YAML file specified by the LMCACHE_CONFIG_FILE environment variable or falls back to reading individual configuration values from environment variables via LMCacheEngineConfig.from_env().
Usage
Use lmcache_get_config at SGLang startup to obtain the LMCache engine configuration. Use is_false when interpreting environment variable strings as boolean flags in the integration layer.
Code Reference
Source Location
- Repository: LMCache
- File: lmcache/integration/sglang/utils.py
- Lines: 1-39
Signature
def is_false(value: str) -> bool: ...
def lmcache_get_config() -> LMCacheEngineConfig: ...
Import
from lmcache.integration.sglang.utils import is_false, lmcache_get_config
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| value | str | Yes (is_false) | String value to check for falsy meaning |
| LMCACHE_CONFIG_FILE | env var | No | Environment variable pointing to a YAML configuration file path |
Outputs
| Name | Type | Description |
|---|---|---|
| bool | bool | True if the string is a falsy value (is_false) |
| config | LMCacheEngineConfig | Loaded engine configuration object (lmcache_get_config) |
Usage Examples
from lmcache.integration.sglang.utils import is_false, lmcache_get_config
# Check a boolean environment variable
if not is_false(os.getenv("LMCACHE_ENABLED", "true")):
config = lmcache_get_config()
# ... initialize LMCache with SGLang ...