You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature/implement built in wrappers that simplifies data source configuration (#7)
* feat: implement multi-layer cache support with LayeredWindowCache and WindowCacheDataSourceAdapter;
refactor: improve async delay handling and exception messages in data fetching methods
* docs: README file has been updated to include validation for layered cache types;
feat: validation method for layered cache compilation on WASM has been added
* docs: update comments for clarity and consistency in IDataSource and LayeredWindowCache;
style: improve formatting in StrongConsistencyModeTests for better readability
* Update tests/SlidingWindowCache.Unit.Tests/Public/LayeredWindowCacheTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* feat: implement ReadOnlyMemoryEnumerable for zero-allocation enumeration of ReadOnlyMemory data;
refactor: update WindowCacheDataSourceAdapter to utilize ReadOnlyMemoryEnumerable for lazy data access;
fix: add null check for domain parameter in LayeredWindowCacheBuilder;
test: add unit tests for LayeredWindowCacheBuilder and WindowCacheDataSourceAdapter
* refactor: update data source adapter to use ReadOnlyMemoryEnumerable for improved memory efficiency;
docs: enhance documentation for ReadOnlyMemoryEnumerable and WindowCacheDataSourceAdapter
---------
Co-authored-by: Mykyta Zotov <mykyta.zotov@ihsmarkit.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README.md
+52Lines changed: 52 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -351,6 +351,58 @@ This is a thin composition of `GetDataAsync` followed by `WaitForIdleAsync`. The
351
351
352
352
`WaitForIdleAsync()` provides race-free synchronization with background operations for tests. Uses "was idle at some point" semantics — does not guarantee still idle after completion. See `docs/invariants.md` (Activity tracking invariants).
353
353
354
+
## Multi-Layer Cache
355
+
356
+
For workloads with high-latency data sources, you can compose multiple `WindowCache` instances into a layered stack. Each layer uses the layer below it as its data source, allowing you to trade memory for reduced data-source I/O.
Wraps an `IWindowCache` as an `IDataSource`, allowing any `WindowCache` to act as the data source for an outer `WindowCache`. Data is retrieved using eventual consistency (`GetDataAsync`).
159
+
160
+
- Wraps `ReadOnlyMemory<TData>` (returned by `IWindowCache.GetDataAsync`) in a `ReadOnlyMemoryEnumerable<TData>` to satisfy the `IEnumerable<TData>` contract of `IDataSource.FetchAsync`. This avoids allocating a temporary `TData[]` copy — the wrapper holds only a reference to the existing backing array via `ReadOnlyMemory<TData>`, and the data is enumerated lazily in a single pass during the outer cache's rematerialization.
161
+
- Does **not** own the wrapped cache; the caller is responsible for disposing it.
**Type**: `sealed class` implementing `IWindowCache<TRange, TData, TDomain>` and `IAsyncDisposable`
168
+
169
+
A thin wrapper that:
170
+
- Delegates `GetDataAsync` to the outermost layer.
171
+
-**`WaitForIdleAsync` awaits all layers sequentially, outermost to innermost.** The outer layer is awaited first because its rebalance drives fetch requests into inner layers. This ensures `GetDataAndWaitForIdleAsync` correctly waits for the entire cache stack to converge.
172
+
-**Owns** all layer `WindowCache` instances and disposes them in reverse order (outermost first) when disposed.
173
+
- Exposes `LayerCount` for inspection.
174
+
175
+
Typically created via `LayeredWindowCacheBuilder.Build()` rather than directly.
0 commit comments