Skip to content

Make cache entry TTL configurable in seconds#117

Open
fa0311 wants to merge 1 commit into
PascalMinder:mainfrom
fa0311:cache-ttl-config
Open

Make cache entry TTL configurable in seconds#117
fa0311 wants to merge 1 commit into
PascalMinder:mainfrom
fa0311:cache-ttl-config

Conversation

@fa0311

@fa0311 fa0311 commented Jun 16, 2026

Copy link
Copy Markdown

What

Adds a cacheTtlSeconds config option to control how long a cached
IP→country entry stays valid before it is refreshed from the API.

Previously the TTL was hardcoded to one month (numberOfHoursInMonth).
Now it is configurable in seconds, defaulting to 30 days when unset so
existing behavior is preserved. As before, the TTL is only enforced when
forceMonthlyUpdate is enabled.

Usage

cacheTtlSeconds: 3600   # refresh entries older than 1 hour
forceMonthlyUpdate: true

Notes

  • The cache schema (ipEntry: Country + Timestamp) is unchanged, so
    no migration is needed — existing cache files keep working.
  • The TTL is evaluated at request time against the entry's creation
    Timestamp, so changing cacheTtlSeconds also affects already-cached
    entries.

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