ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/llms-txt-hub / packages/cli/src/lib/cache.ts

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/llms-txt-hub / packages/cli/src/lib/cache.ts
DateNot specified in source
RepositoryJanady13/llms-txt-hub
Revisione0f4bf978d4df168369c7601d9c5f5ea89e84377
Branchmain
Path or archive memberpackages/cli/src/lib/cache.ts
Original SHA-2566e9987f65ea8fc467ada24a1ddfabd223c8bc1cfb3b3d37357cd6279b56a0350
Git blob SHA1ee32eaf36481c9857bf822526463b43a0a035a2
Reading-copy SHA-2566e9987f65ea8fc467ada24a1ddfabd223c8bc1cfb3b3d37357cd6279b56a0350

Original source ↗

Recovered source transcript

import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs' import { homedir } from 'node:os' import { join } from 'node:path' import type { RegistryEntry } from '../types/index.js' const CACHE_DIR = join(homedir(), '.cache', 'llmstxt') const CACHE_FILE = join(CACHE_DIR, 'registry.json') const CACHE_TTL_MS = 24 * 60 * 60 * 1000 // 24 hours /** * Ensure the cache directory exists on disk. */ function ensureCacheDir(): void { mkdirSync(CACHE_DIR, { recursive: true }) } /** * Return cached registry entries if the cache is fresh, or null. */ export function getCachedRegistry(): RegistryEntry[] | null { try { if (!existsSync(CACHE_FILE)) return null const stat = statSync(CACHE_FILE) const age = Date.now() - stat.mtimeMs if (age > CACHE_TTL_MS) return null const raw = readFileSync(CACHE_FILE, 'utf-8') const parsed: unknown = JSON.parse(raw) if (!Array.isArray(parsed)) return null // Each element is validated by the caller (validateRegistryData in registry.ts) const entries: RegistryEntry[] = parsed return entries } catch { return null } } /** * Persist registry entries to the local cache file. */ export function setCachedRegistry(entries: RegistryEntry[]): void { try { ensureCacheDir() writeFileSync(CACHE_FILE, JSON.stringify(entries), 'utf-8') } catch { // cache write failure is non-fatal } }

Search equations, builds, manuscript text, and recovered sources.