Pocache (poh-cash (/poʊ kæʃ/)), Preemptive optimistic cache, is a lightweight in-app caching package. It introduces preemptive cache updates, optim

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-10-11 13:30:05

Pocache (poh-cash (/poʊ kæʃ/)), Preemptive optimistic cache, is a lightweight in-app caching package. It introduces preemptive cache updates, optimizing performance in concurrent environments by reducing redundant database calls while maintaining fresh data. It uses Hashicorp's Go LRU package as the default storage.

Given a cache expiration time and a threshold window, Pocache triggers a preemptive cache update when a value is accessed within the threshold window. Example:

When a key is fetched between 9-10 minutes (within the threshold window), Pocache initiates an update for that key (preemptive). This ensures fresh data availability, anticipating future usage (optimistic).

In highly concurrent environments (e.g., web servers), multiple requests might try to access the same cache entry simultaneously. Without preemptive updates, the system would query the underlying database multiple times until the cache is refreshed.

Additionally by debouncing these requests, Pocache ensures only a single update is triggered, reducing load on both the underlying storage and the application itself.

Leave a Comment