MCPcopy Index your code
hub / github.com/TanStack/db / parsePersistedQueryRetentionEntry

Function parsePersistedQueryRetentionEntry

packages/query-db-collection/src/query.ts:782–815  ·  view source on GitHub ↗
(
      value: unknown,
      expectedHash: string,
    )

Source from the content-addressed store, hash-verified

780 }
781
782 const parsePersistedQueryRetentionEntry = (
783 value: unknown,
784 expectedHash: string,
785 ): PersistedQueryRetentionEntry | undefined => {
786 if (!value || typeof value !== `object`) {
787 return undefined
788 }
789
790 const record = value as Record<string, unknown>
791 if (record.queryHash !== expectedHash) {
792 return undefined
793 }
794
795 if (record.mode === `until-revalidated`) {
796 return {
797 queryHash: expectedHash,
798 mode: `until-revalidated`,
799 }
800 }
801
802 if (
803 record.mode === `ttl` &&
804 typeof record.expiresAt === `number` &&
805 Number.isFinite(record.expiresAt)
806 ) {
807 return {
808 queryHash: expectedHash,
809 mode: `ttl`,
810 expiresAt: record.expiresAt,
811 }
812 }
813
814 return undefined
815 }
816
817 const runPersistedRetentionMaintenance = (task: () => Promise<void>) => {
818 persistedRetentionMaintenance = persistedRetentionMaintenance.then(

Calls

no outgoing calls

Tested by

no test coverage detected