// Generated by bynkc — do not edit by hand.
// context cache.store

import { Ok, Err, Some, None, type Result, type Option, type ValidationError } from "../runtime.js";

import * as bynk_cloudflare from "../bynk/cloudflare.js";

export const cache = {
  async call(key: string, value: string, deps: { Kv: bynk_cloudflare.Kv }): Promise<Option<string>> {
    const previous = await deps.Kv.get(key);
    const __r0 = await deps.Kv.put(key, value);
    const __r1 = await deps.Kv.delete("stale");
    return previous;
  },
};

export interface CacheStoreDeps {
  readonly Kv: bynk_cloudflare.Kv;
}

export function makeSurface(deps: CacheStoreDeps) {
  return {
    async cache(key: string, value: string): Promise<Option<string>> {
      return cache.call(key, value, deps);
    },
  };
}

