kibertoad / layered-loader

Data loader with support for caching and fallback data sources
MIT License
43 stars 4 forks source link

Clarification regarding distributed invalidation using redis pubsub #274

Closed mplibunao closed 12 months ago

mplibunao commented 12 months ago

I was reading the updates on the docs and I read the following:

  • InMemoryCache - synchronous in-memory cache. Offers highest possible performance, but is generally very short-lived, as it cannot be explicitly invalidated within a distributed system

This got me confused as I might be misunderstanding how invalidation works with redis pubsub in this package. My initial understanding was that using a notification pair allows invalidating the in-memory cache of the distributed nodes. Is this true or does redis pubsub only invalidate async caches?

Thanks for the work on this package btw.

Update:

Upon reading the tests on https://github.com/kibertoad/layered-loader/blob/main/test/redis/RedisNotificationPublisher.spec.ts#L90 it seems redis pubsub does indeed invalidate the in-memory cache.

kibertoad commented 12 months ago

Thank you for reaching out! This is an older part of the documentation, which is no longer true. You are right, notification pair addresses this problem. Will update the docs accordingly.

kibertoad commented 12 months ago

@mplibunao Documentation updated in https://github.com/kibertoad/layered-loader/commit/7b43bf84de537e9fbbd8899c430448719e2b6f4b, thanks again!