Configuration Normalization and Cache Optimization for Yanhuobao Service
By consolidating all Yanhuobao category settings into a single Mach‑managed configuration defined by a JSON schema and introducing a generic Guava LoadingCache with a ConfigValueParser, the service now adds new categories with just three fields, reduces parsing overhead, lowers maintenance costs, and improves consistency and QPS performance.
Rapid iteration of business systems inevitably introduces configuration "code smells". The Yanhuobao service, which provides inspection reports for high‑value items on Xianyu, faced scattered configuration across multiple systems and hard‑coded values, leading to high maintenance cost and long release cycles when adding new categories.
The optimization consolidates all category‑specific settings into a single atomic configuration using the Mach configuration platform. Each new category now requires only three configuration items: an introduction page URL (string), the inspection fee amount (number), and a list of upgradeable sub‑categories (array of strings).
Developers define a JSON Schema for the "Yanhuobao Config Set" in Mach, create an instance with effective time, priority, and fill the three fields. Mach generates appropriate UI controls (text box, number input, array list) for each type.
To avoid repeated parsing and redundant caching, a generic configuration cache pool based on Guava's LoadingCache is introduced. A ConfigValueParser interface allows each configuration to implement its own parsing logic, returning a typed YhbConfigDO object.
Usage example:
YhbConfigDO yhbConfigDO = configMachReader.get(CONFIG_MACH_ID);The cache stores the parsed YhbConfigDO locally, reducing QPS pressure while the configuration does not require real‑time updates.
In summary, the configuration normalization and shared cache pool simplify adding new categories, lower maintenance overhead, and improve consistency across the Yanhuobao product chain.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
