Skip to content

Instantly share code, notes, and snippets.

@cprice404
Created March 17, 2023 00:17
Show Gist options
  • Save cprice404/f9240cba4a31050299ce18899ffb65cf to your computer and use it in GitHub Desktop.
Save cprice404/f9240cba4a31050299ce18899ffb65cf to your computer and use it in GitHub Desktop.
import {
CacheClient,
Configurations,
CredentialProvider,
ListCaches,
} from '@gomomento/sdk';
async function main() {
const momento = new CacheClient({
configuration: Configurations.Laptop.v1(),
credentialProvider: CredentialProvider.fromEnvironmentVariable({
environmentVariableName: 'MOMENTO_AUTH_TOKEN',
}),
defaultTtlSeconds: 60,
});
const cachesResponse = await momento.listCaches();
let caches;
if (cachesResponse instanceof ListCaches.Success) {
caches = cachesResponse.getCaches();
} else {
throw new Error('List caches failed');
}
for (const cache of caches) {
console.log(`Deleting cache: ${cache.getName()}`);
await momento.deleteCache(cache.getName());
}
}
main().catch(e => {
throw e;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment