ISwr interface
ISwr interface
Section titled “ISwr interface”Provides stale-while-revalidate caching with user-supplied fetchers. Register via AddSwrForBlazor or AddSwrForAspNetCore.
public interface ISwr : IDisposableMembers
Section titled “Members”| name | description |
|---|---|
| Invalidate(…) | Removes a specific cache entry by exact key. |
| InvalidateAll() | Removes all cache entries. |
| InvalidateByPrefix(…) | Removes all cache entries whose keys start with the given prefix. Useful for invalidating related endpoints (e.g., all “/api/users” entries). |
| MutateAsync(…) | Executes a mutation action and invalidates the specified cache keys. If the mutation throws, no cache keys are evicted. |
| Use<T>(…) | Returns cached data immediately (if available) and revalidates in the background using the provided fetcher. The caller owns how data is retrieved — SWR only manages the cache. |
| Use<T,TArg>(…) | Returns cached data for a composite key made of a URL and one additional argument. The tuple parts form the cache key (so different argument values yield separate cache entries) and are passed individually to the fetcher. |
| Use<T,TArg1,TArg2>(…) | Returns cached data for a composite key made of a URL and two additional arguments. The tuple parts form the cache key and are passed individually to the fetcher. |