Created
March 17, 2023 00:17
-
-
Save cprice404/f9240cba4a31050299ce18899ffb65cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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