import Redis from 'ioredis';
export const redis = new Redis(process.env.REDIS_URL || 'redis://localhost:6379');
export async function getExchangeRate() {
  const cache = await redis.get('usd_idr_rate');
  if (cache) return parseFloat(cache);
  const rate = 15500;
  await redis.set('usd_idr_rate', rate, 'EX', 43200);
  return rate;
}
