Skip to content

Conversation

@Yuripetusko
Copy link
Contributor

@Yuripetusko Yuripetusko commented Nov 5, 2025

Fixes #93

Problem:

The cache system wasn't actually using TTL for Redis. While RedisCacheStore has a setWithTTL() method that uses Redis SETEX, all cache writes were calling regular set() instead. This meant:

  • Redis keys never expired
  • Cache entries piled up in memory
  • Had to rely on eviction policies instead of proper TTL management

Also, when using createCached(), you had to pass ttl twice - once to createCached() and again when calling the returned function. Pretty confusing.

Changes:

  • Added optional setWithTTL to CacheStore interface
  • Created helper function that uses setWithTTL when available, falls back to set() otherwise
  • Updated all 4 cache write locations to use the helper
  • Forward ttl from createCached() to createCachedFunction() so you only specify it once
  • Exported missing types: CacheBackendConfig, CacheStore, CacheEntry, and createCacheBackend (these were referenced in README but not exported)

…ries

- Add optional setWithTTL method to CacheStore interface
- Create helper function to use setWithTTL when available
- Replace all store.set() calls with TTL-aware helper
- Export missing types (CacheBackendConfig, CacheStore, CacheEntry) and createCacheBackend function
- Forward TTL option from createCached to createCachedFunction for consistency
- Fixes issue where Redis keys were stored without expiration
- Fixes issue where TTL needed to be specified twice when using createCached
@vercel
Copy link

vercel bot commented Nov 5, 2025

@Yuripetusko is attempting to deploy a commit to the Pontus Abrahamsson's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Cache: Redis store's setWithTTL is never used

1 participant