# `@lazarv/react-server/memory-cache`

Default in-memory cache provider. Exposes `useCache`, `invalidate`, and the client-side helpers used when the runtime's built-in cache is active.

## Functions

### `invalidate`

```ts
function invalidate(keys: string[]): Promise<void>;
```

Invalidate the cache for the given keys.

**Parameters**

- `keys` — The keys to invalidate

**Returns** — A promise that resolves when the cache is invalidated

### `useCache`

```ts
function useCache<T>(keys: string[], value: (() => Promise<T>) | T, ttl?: number, force?: boolean): Promise<T>;
```

Get from cache or set the value in the cache with the given keys for the given time to live.

**Parameters**

- `keys` — The keys to cache the value with
- `value` — The value to cache
- `ttl` — The time to live in milliseconds
- `force` — Whether to force cache overwrite

**Returns** — The cached value

```tsx
import { useCache } from '@lazarv/react-server';

export default function App() {
 const data = useCache(['todos'], async () => {
  const response = await fetch('https://jsonplaceholder.typicode.com/todos');
  return response.json();
 }, 1000);

 return <p>{data}</p>;
}
```

## Types

### `StorageCache`

```ts
type StorageCache = import("./storage-cache").default;
```
