Skip to content

@ogygia/devtools · API

@ogygia/devtools/profiler/storage/redis

RedisStore, a profiler report store every instance can share.

On this page

This page is generated from the package’s own .d.ts files on every build, so the signatures, descriptions and examples below always match the source.

Exports RedisStore

import { … } from '@ogygia/devtools/profiler/storage/redis';

RedisStore

class

A report store on Redis, for a fleet that already runs one or a serverless host on a hosted Redis. Reports are strings under <prefix>report:<id>, listed by the sorted set <prefix>reports (scored by created); visits are <prefix>visit:<key>, listed per page. The prefix defaults to og:. It keeps 1000 reports at most, whatever the host prunes to, and 2000 visits per page.

// src/hooks.server.ts import { setProfilerStore } from '@ogygia/devtools/profiler/storage'; import { RedisStore } from '@ogygia/devtools/profiler/storage/redis'; setProfilerStore(new RedisStore('redis://localhost:6379')); // or a client already made (node-redis or ioredis) setProfilerStore(new RedisStore(myClient));

Given a URL, it imports node-redis, or ioredis when node-redis is not installed; a node-redis that cannot connect fails with its own error. Either client's writes are one call each, in its own form. ttlSeconds expires reports on their own; an expired id leaves its index the next time the list is read. After close(), the next call connects again.

RedisStore.kind

A name for the dashboard ("sqlite", "redis", "postgres", "memory").

RedisStore.constructor

RedisStore.init

Called once before first use — create tables, connect, etc. Optional.

RedisStore.putReport

Write (or overwrite) a report.

RedisStore.getReport

Read a report's full dump JSON, or null when absent.

RedisStore.listReports

The most recent reports (summaries), newest first.

RedisStore.deleteReport

Remove a report.

RedisStore.prune

Keep at most keep reports, dropping the oldest — the store's own LRU, called after a put.

RedisStore.putVisit

RedisStore.listVisits

RedisStore.close

Release connections. Optional.

class RedisStore implements ProfilerStore {/*…*/}
readonly kind: string;
constructor(client: RedisLike | string, opts?: {
    ttlSeconds?: number;
    prefix?: string;
  });
init(): Promise<void>;
putReport(rec: ProfilerRecord): Promise<void>;
getReport(id: string): Promise<string | null>;
listReports(limit?: number): Promise<ProfilerSummary[]>;
deleteReport(id: string): Promise<void>;
prune(keep: number): Promise<void>;
putVisit(rec: ProfilerVisitRecord): Promise<void>;
listVisits(page: string, limit?: number): Promise<ProfilerVisitRecord[]>;
close(): Promise<void>;