context cache.secured

consumes bynk { Secrets }
consumes bynk.cloudflare { Kv }

service vault {
  on call(key: String) -> Effect[Option[String]] given Kv, Secrets {
    let fallback <- Secrets.get("CACHE_FALLBACK")
    let hit <- Kv.get(key)
    match hit {
      Some(v) => Some(v),
      None => fallback,
    }
  }
}
