Skip to content

fix#885

Open
heymide wants to merge 2 commits into
rinafcode:mainfrom
heymide:caching-service
Open

fix#885
heymide wants to merge 2 commits into
rinafcode:mainfrom
heymide:caching-service

Conversation

@heymide

@heymide heymide commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Description

Close: #812
I've successfully fixed the thundering herd issue in CachingService.getOrSet ! Here's what was changed:

Injected DistributedLockService into CachingService using the @optional() decorator, which allows graceful fallback to the old behavior if the lock service isn't available
Modified getOrSet method :
Added lock key: lock:cache:{key}
Added configurable parameters: lockTimeoutMs , pollIntervalMs , maxWaitMs
On cache miss, tries to acquire a lock first
Lock holders: double-check cache, run factory, store result, then release lock
Non-lock holders: poll cache (with jitter) until either the result is available or timeout is reached
Added a private sleep helper to handle polling delays

Related Issue

Closes #812

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • No console errors
  • Uses Lucide icons consistently
  • Responsive design implemented
  • Starknet best practices followed

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.

2 participants