
probably need to add redis and redis dependancies

the redis info host/port/username/password are all actual values and should be used as is.

the rest is an example we can use to build out our logic and functions.

need logging to show we are connected and data is being added and updated to cache.  can use console for this

caching
1&2 must make it so that the show folder button on the info page is readily available and that
files are instantly available once the show job folder button is clicked. should not be any loading
time.
1) get all data associated with the initial load and add to redis (keep fresh 300 seconds)
2) get files/folders/links for those jobs and add to redis (keep fresh 300 seconds)
3) get all other jobs by page if needed and add to redis (keep fresh 3600 seconds)
4) get files/folders/links for all other jobs by page if needed and add to redis (keep fresh 3600 seconds)

const Redis = require('ioredis');

const cache = new Redis({
  host: '127.0.0.1',
  port: 6379,
  username: 'prism',
  password: 'Qu+twDwf+DdWFt/aPopFHae074RY9JqiP98BuiPanr4=',
});

cache.on('connect', () => console.log('✅ Connected to Valkey'));

async function getHotData(page) {
  const cacheKey = `jobs:page:${page}`;
  
  // 1. Try to get from cache
  const cached = await cache.get(cacheKey);
  if (cached) {
    // Optional: Reset TTL on access to keep it "hot" (Sliding TTL)
    await cache.expire(cacheKey, 3600); 
    return JSON.parse(cached);
  }

  // 2. Fetch from source (PocketBase/Graph API)
  const freshData = await fetchFromYourAPI(page); 

  // 3. Store in cache for 1 hour (3600 seconds)
  await cache.set(cacheKey, JSON.stringify(freshData), 'EX', 3600);
  
  return freshData;
}

Key 2025 Best Practices
Use Descriptive Keys: Structure your keys to avoid collisions, such as app:resource:id:page.
Set Appropriate TTLs: For training data you want to keep frequent, a TTL of 300 to 3600 seconds (5–60 minutes) is standard.
Monitor Hit Rates: Use the command valkey-cli --user prism -a "your_pass" info stats to check your keyspace_hits vs keyspace_misses. A high hit rate means your "Full Pipe" is working efficiently. 