mirror of
https://github.com/HeyPuter/puter.git
synced 2026-09-14 09:15:45 +00:00
* Revert "fix: quick fix for config context issue" This reverts commit0c06040e6c. * Revert "sync: package-lock.json" This reverts commit1e1bd0f2ba. * Revert "devex: misc log cleanup" This reverts commita64a786528. * Revert "devex: minimal first page load logs" This reverts commit196e463c59. * Revert "devex: minimal initialization logs" This reverts commitea9c222c09. * Revert "fix: add missing await in kv example extension" This reverts commit9b34e67d0d. * Revert "devex: reduce logs at init" This reverts commitfa221149c2. * Revert "sync: package.json changes" This reverts commit4db73d75a5. * Revert "fix: remove unused AWS SDK v2 import" This reverts commit4d8692fd31. * Revert "devex: hide `npm install` output unless it fails" This reverts commitfe03a4b598. * Revert "devex: rollup via module instead of subprocess" This reverts commit360082d8bd. * Revert "devex: webpack via module instead of subprocess" This reverts commit1449d12b0e.
31 lines
927 B
JavaScript
31 lines
927 B
JavaScript
const { kv } = extension.import('data');
|
|
const { sleep } = extension.import('utilities');
|
|
|
|
// "kv" is load ready to use before the 'init' event is fired.
|
|
extension.on('init', async () => {
|
|
kv.set('example-kv-key', 'example-kv-value');
|
|
|
|
console.log('kv key has', await kv.get('example-kv-key'));
|
|
|
|
await kv.expire({
|
|
key: 'example-kv-key',
|
|
ttl: 1000 * 60, // 1 minute
|
|
});
|
|
|
|
// This AIIFE demonstrates how "kv.expire" works.
|
|
// We cannot simply "await" this - otherwise we block init!
|
|
(async () => {
|
|
// wait for 30 seconds...
|
|
await sleep(30 * 1000);
|
|
|
|
console.log('kv key still has value', await kv.get('example-kv-key'));
|
|
|
|
// wait for 30 more seconds
|
|
await sleep(30 * 1000);
|
|
// and just a little bit longer
|
|
// await sleep(100);
|
|
|
|
console.log('kv key should no longer have the value', kv.get('example-kv-key'));
|
|
})();
|
|
});
|