Data APIs

cache

Edit this page

cache is a deprecated alias for query.


Import

import { cache } from "@solidjs/router";

Type

const cache: typeof query;

Parameters

cache has the same parameters as query.


Return value

  • Type: CachedFunction<T>

cache returns the same value as query.


Behavior

  • cache and query reference the same function.
  • Cache keys, reuse behavior, static methods, and revalidation behavior are the same as query.

Examples

Basic usage

import { cache } from "@solidjs/router";
const getUser = cache(async (id: string) => {
const response = await fetch(`/api/users/${id}`);
return response.json();
}, "user");

Report an issue with this page