Open pi0 opened 3 years ago
Not sure wjat you mean with this, but I had this idea to allow setting the cache via s3 endpoints and then expose it via a cloudfront distribution.
I'm currently attempting to create the s3 driver. Wdyt of adding a cdn option to drivers like s3 and maube other bucket providers?
It would be something like this:
driver({
bucket: 'my-site',
region: 'eu-west-1',
basePath: '/cache',
acl: 'public-read',
...iamCredentials,
cloudfrontDistribution: { ... }
}
For now I am using something like this (for similar problem to #379 ), are there any downsides to this approach ?
import { setTimeout } from "node:timers/promises";
import { createStorage } from "unstorage";
import { fsCacheDriver } from "./driver";
const storage = createStorage({
driver: fsCacheDriver({ base: "./db", freshness: "5s" }),
});
await storage.setItem("foo", "bar");
let foo = await storage.getItem("foo");
console.log(foo); // output - bar
await setTimeout(5000);
foo = await storage.getItem("foo");
console.log(foo); // output - undefined
(some good ideas in https://github.com/unjs/unstorage/issues/88)