Skip to content

Issue 7: Offline-First Local Cache Management Engine Using IndexedDB - #28

Merged
elizabetheonoja-art merged 1 commit into
Utility-Protocol:mainfrom
KarenZita01:feat/issue-7-offline-cache
Jun 17, 2026
Merged

Issue 7: Offline-First Local Cache Management Engine Using IndexedDB#28
elizabetheonoja-art merged 1 commit into
Utility-Protocol:mainfrom
KarenZita01:feat/issue-7-offline-cache

Conversation

@KarenZita01

Copy link
Copy Markdown
Contributor

Closes #7

Summary

Implements a full offline-first cache management engine on top of the existing IndexedDB layer, enabling field engineers to operate utility meters in areas with intermittent or no connectivity.

Changes

\src/services/cache.ts\

  • Offline queue (\offline-queue\ object store, DB v2): when
    avigator.onLine === false, \cacheSet\ enqueues mutations instead of writing directly
  • **
    eplayOfflineQueue()**: on reconnect, replays queued writes in FIFO order with exponential backoff (1s, 5s, 15s, 30s, 60s) and max 5 retries
  • *\enqueueOfflineWrite()* / **\getOfflineQueueLength()**: manage the offline queue
  • **\cacheSetBulk()**: batch writes coalesced via
    equestAnimationFrame\ for efficient bulk mutations
  • All existing operations remain unchanged (backward compatible, DB upgrade from v1)

\src/hooks/useOnlineStatus.ts\

  • Tracks
    avigator.onLine\ state via \online/\offline\ events
  • Automatically triggers
    eplayOfflineQueue()\ when coming back online
  • Polls queue length every 10s and exposes \pendingCount\

Verification

  • ESLint passes
  • TypeScript compilation (
    px tsc --noEmit) passes

- Offline queue store (DB v2) when navigator.onLine === false
- replayOfflineQueue() with exponential backoff (1s-60s, max 5 retries)
- cacheSetBulk() with requestAnimationFrame batching
- useOnlineStatus hook for online/offline detection
@elizabetheonoja-art
elizabetheonoja-art merged commit bfc239f into Utility-Protocol:main Jun 17, 2026
3 checks passed
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.

Issue 7: Offline-First Local Cache Management Engine Using IndexedDB

2 participants