Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizing Multicaching Efficiency: Dynamic Data Migration Between Cache Levels #639

Closed
EliezerMafra opened this issue Feb 12, 2024 · 3 comments
Assignees

Comments

@EliezerMafra
Copy link

Is your feature request related to a problem? Please describe.
Imagine a scenario where we implement multicaching with two cache managers, operating as distinct levels:

  • Memory Cache
  • Redis Cache

While these caches have different TTLs (Time To Live), an issue arises when the memory cache expires. At that point, multicaching resorts solely to fetching data from Redis until it also expires. This contradicts the intended purpose of multicaching, which is to minimize Redis calls by efficiently storing data in memory.

Describe the solution you'd like
To address this, we propose an enhancement where, in situations where data is not found in the first cache level but is available in the second, the system should dynamically copy the data from the second level to the first. Subsequent calls would then benefit from improved performance, as data retrieval occurs primarily from the faster memory cache.

Consider the following workflow:

  • Upon the first call, if data isn't found in the primary cache level, the system queries the secondary cache.
  • Upon finding the data in the secondary cache, it's copied to the primary cache.
  • Subsequent calls retrieve data directly from the primary cache, thus enhancing performance by reducing reliance on the secondary cache.
@EliezerMafra EliezerMafra changed the title Auto saving in upper levels on multicaching Optimizing Multicaching Efficiency: Dynamic Data Migration Between Cache Levels Feb 12, 2024
@jaredwray
Copy link
Owner

@EliezerMafra thanks for bringing this to our attention. Would love to see a test example of this and then we can get a fix going.

@jaredwray jaredwray self-assigned this Feb 14, 2024
@jaredwray
Copy link
Owner

closing until we see more on this.

@erkstruwe
Copy link

This already works, but only when using wrap. See #253.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants