Smart RESTful API Design with Adaptive Auto-Cache Feature Using Golang and Gin Framework
Downloads
Abstract
The rapid growth of digital applications demands RESTful APIs capable of efficiently handling high request loads. Conventional caching approaches with static Time-to-Live (TTL) values fail to adapt to dynamic user access patterns, resulting in memory inefficiency or uncontrolled performance degradation. This study designs and develops a RESTful API using Golang and the Gin Framework, equipped with a duration-based adaptive auto-cache mechanism. The system implements the formula TTL_runtime = TTL_baseline + AdaptCoeff x D_key, where TTL is dynamically adjusted based on the active duration of each cache key. A monthly evaluation cycle identifies hot keys through three pillars: daily first access time (Pillar 1), cache hit count (Pillar 2), and total active duration as SuggestedTTL (Pillar 3). Testing results demonstrate that the adaptive cache successfully reduced the maximum response time by 68.8%, from 711 ms to 222 ms, with hit ratios reaching 99.83%-99.95% across all traffic intensity variations (200-2,000 requests). Cache misses consistently numbered exactly one per session regardless of request volume, proving the effectiveness of the cache-first mechanism. The monthly evaluation cycle successfully identified 8 hot keys with SuggestedTTL values ranging from 20.4 to 48.6 minutes, proportional to actual usage patterns.
Keywords:
RESTful API Adaptive Auto-Cache Golang Gin Framework Time-to-Live Cache InvalidationLicense
Copyright (c) 2026 dita aulia, Ahmad Rahmatika

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
International Journal of Advanced Reasoning and Computational Intelligence (IJARCI) © 2025 by INSITECS is licensed under CC BY-SA 4.0


