Skip to content

Add multi cache provider with cascade fallback support#145

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/add-multi-cache-provider
Draft

Add multi cache provider with cascade fallback support#145
Copilot wants to merge 4 commits intomasterfrom
copilot/add-multi-cache-provider

Conversation

Copy link
Contributor

Copilot AI commented Dec 20, 2025

Description

Introduces a new "multi" cache provider that cascades through multiple cache backends in order, returning the first hit. Enables multi-tier cache hierarchies (e.g., memory → redis → file).

Core behavior:

  • Reads: Check caches sequentially, return first match
  • Writes: Broadcast to all caches in parallel
  • Deletes: Remove from all caches in parallel
  • Increments: Atomic in first cache, sync result to others

Config example:

{
  caches: {
    l1: { provider: 'memory', config: { maxSize: 1000 } },
    l2: { provider: 'redis', config: { url: 'redis://...' } },
    tiered: {
      provider: 'multi',
      config: { caches: ['l1', 'l2'] }
    }
  }
}

Usage:

const cache = cache('tiered');
await cache.put('key', value);     // → writes to l1 and l2
const hit = await cache.get('key'); // → checks l1, then l2

Implementation:

  • MultiCacheProvider class implementing CacheProviderInterface
  • Config resolver in cache facade converts cache names to provider instances
  • Validation prevents circular references and nested multi caches
  • Requires minimum 1 cache in array

Checklist

  • lint/prettier
  • updated docs with new feature/details
  • added tests that cover changes
  • Add jsdocs for any added function/class
Original prompt

This section details on the original issue you should resolve

<issue_title>multicache provider</issue_title>
<issue_description>i want to introduce a new cache where it gets two or more other caches.

it should always use first cache and if no result is found then check the next cache.

make it possible to pass caches as array and account for array length to be longer or equal to one.

call this "multi" cache provider.

when adding it to pashmak make sure the config uses name of other caches already defined.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 20, 2025 17:53
Co-authored-by: devbro1 <29712935+devbro1@users.noreply.github.com>
Co-authored-by: devbro1 <29712935+devbro1@users.noreply.github.com>
Co-authored-by: devbro1 <29712935+devbro1@users.noreply.github.com>
Copilot AI changed the title [WIP] Add multi cache provider to handle multiple caches Add multi cache provider with cascade fallback support Dec 20, 2025
Copilot AI requested a review from devbro1 December 20, 2025 18:00
@devbro1
Copy link
Owner

devbro1 commented Jan 29, 2026

change in approach, multicache shall recieve an array of caches to work with, not configs
@copilot

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.

multicache provider

2 participants