@Leo Thanks Leo. Is there pricing available for using the Cache API in a worker? I can't find it.
@Leo Thanks Leo. Is there pricing available for using the Cache API in a worker? I can't find it.

nodejs_compat and node_compat together. node_compat is an old and legacy way for wrangler to inject polyfills and globals that emulate Node.js things. nodejs_compat is actually real node.js support for various modules, straight from the runtime. It's the recommended way to do things nowadays.node_compat for the recommended pg driver today. You can use postgres.js with nodejs_compat, but it doesn't have full support with hyperdrive yet, mainly for things like caching.crypto.subtle which is built into all Workers, even without node compat: https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#digestdigest using SHA-1name = "foo" and don't specify a name specifically under env.dev, then that Worker when ran with --env dev is now called foo-dev.request.url when calling fetch(), which wouldn't exist within the context of a scheduled worker?wrangler tailimport crypto from 'node:crypto';
class CryptoCls {
static hashString(_text?: string): string {
let hash = '';
if (_text) {
hash = crypto.createHash('sha256').update(_text).digest('hex');
}
return hash;
}
}
app.get('/', async (context: Context) => {
class RedisCacheAside {
static getHashKey(_filter: any) {
let retKey = '';
if (_filter) {
retKey = 'CACHE_ASIDE_' + CryptoCls.hashString(JSON.stringify(_filter));
}
return retKey;
}
}
const query = {
color: {
equals: 'mint',
},
};
let data = RedisCacheAside.getHashKey(query);
const client = new Client(context.env.HYPERDRIVE);
await client.connect();
const result = await client.query('SELECT * FROM user_courses');
return context.json(data);
});node_compat = truenodejs_compatnodejs_compatnodejs_compatnodejs_compatclass RedisCacheAside {
static getHashKey(_filter: any) {
let retKey = '';
if (_filter) {
retKey = 'CACHE_ASIDE_' + CryptoCls.hashString(JSON.stringify(_filter));
}
return retKey;
}
}
const query = {
color: {
equals: 'mint',
},
};
let data = RedisCacheAside.getHashKey(query);✘ [ERROR] TypeError: crypto_default.createHash is not a function
at CryptoCls.hashString
(file:///Users/nicolethomas/Desktop/Membership/hono/src/features/common/crypto.ts:7:21)
at RedisCacheAside.getHashKey
(file:///Users/nicolethomas/Desktop/Membership/hono/src/index.ts:59:45)
at null.<anonymous> (file:///Users/nicolethomas/Desktop/Membership/hono/src/index.ts:69:30)
at dispatch
(file:///Users/nicolethomas/Desktop/Membership/hono/node_modules/.pnpm/hono@4.2.2/node_modules/hono/dist/compose.js:29:23)
at null.<anonymous>
(file:///Users/nicolethomas/Desktop/Membership/hono/node_modules/.pnpm/hono@4.2.2/node_modules/hono/dist/compose.js:30:20)
at null.<anonymous> (file:///Users/nicolethomas/Desktop/Membership/hono/src/index.ts:31:9)
at dispatch
(file:///Users/nicolethomas/Desktop/Membership/hono/node_modules/.pnpm/hono@4.2.2/node_modules/hono/dist/compose.js:29:23)
at null.<anonymous>
(file:///Users/nicolethomas/Desktop/Membership/hono/node_modules/.pnpm/hono@4.2.2/node_modules/hono/dist/compose.js:30:20)
at poweredBy2
(file:///Users/nicolethomas/Desktop/Membership/hono/node_modules/.pnpm/hono@4.2.2/node_modules/hono/dist/middleware/powered-by/index.js:4:11)
at dispatch
(file:///Users/nicolethomas/Desktop/Membership/hono/node_modules/.pnpm/hono@4.2.2/node_modules/hono/dist/compose.js:29:23)postgres.jsdigestasync function hashString(input) {
const encoder = new TextEncoder();
const data = encoder.encode(input);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
return bufferToHex(hashBuffer);
}
function bufferToHex(buffer) {
const view = new DataView(buffer);
let hex = '';
for (let i = 0; i < view.byteLength; i += 1) {
const byte = view.getUint8(i).toString(16);
hex += byte.padStart(2, '0');
}
return hex;
}name = "foo"env.dev--env devfoo-devrequest.urlfetch()wrangler tail[env.dev.vars]
API_HOST = "localhost"
API_PORT = "9000"
[env.production.vars]
API_HOST = "engine.corsa.club"
API_PORT = "443"