TanStackT
TanStack3y ago
2 replies
progressive-amaranth

Can I use custom QueryCache with react-query?

Hi, I have an application where I buffer (cache) data into in-memory cache periodically. The cache structure is nested object which is optimized to read data efficiently. I have BufferManager class to manage writing and reading of cache and BufferClient to handle data fetching logic.
The app is similar to hls video player, but instead of buffering video frames, I buffer json objects in order to draw them on canvas.

Can I use my custom BufferManager as QueryCache so that I can use react-query to handle data fetching? For example, I want use useInfiniteQuery

My buffer (cache) structure looks like this:
type UniqueKey = string;

type Buffer = Record<UniqueKey,  SnapshotGroup>
type SnapshotGroup = Record<number, Array<Snapshot>>

type Snapshot = {
  datetime: string;
  x: number;
  y: number;
  z: number;
} 
Was this page helpful?