interface cache {
    // A resource for caching data with optional expiration.
    resource cache {
        // Initialize a new named cache with the provided size & TTL. If the cache already exists, it'll be re-used.
        init: static func(name: string, size: u32, ttl-ms: option<u64>) -> cache;
        // Retrieves a value from the cache by key.
        // Returns None if the key does not exist or has expired. In that case the cache entry is reserved
        // and the instance MUST call insert to add the value. Other instances will wait until `timeout` expires
        // for the value to appear.
        get-or-reserve: func(key: string, timeout-ms: u64) -> option<list<u8>>;
        // Sets a value in the cache with the specified key.
        // Optional ttl-ms parameter sets the time-to-live in milliseconds after which the value expires.
        // If ttl-ms is None, the value will not expire automatically.
        insert: func(key: string, value: list<u8>);
    }
}
