:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
export abstract class ScopedCache<T extends Record<string, any>> {
constructor(readonly scope: string) {}
abstract get<K extends keyof T>(key: K): Promise<T[K] | undefined>
abstract set<K extends keyof T>(key: K, value: T[K]): Promise<void>
abstract setIfAbsent<K extends keyof T>(key: K, value: T[K]): Promise<boolean>
abstract delete<K extends keyof T>(key: K): Promise<void>
abstract clear(): Promise<void>
async setMany(entries: Partial<{ [K in keyof T]: T[K] }>): Promise<void> {
const promises: Promise<void>[] = []
for (const key of Object.keys(entries) as (keyof T)[]) {
const value = entries[key]
if (value !== undefined) {
promises.push(this.set(key, value as T[typeof key]))
}
}
await Promise.all(promises)
}
}