Caching Cryptographic Materials
This feature allows you to cache cryptographic materials using the NodeCachingMaterialsManager. The cache is configured with a maximum age, maximum bytes encrypted, and maximum messages encrypted to ensure efficient and secure reuse of cryptographic materials.
const { NodeCachingMaterialsManager } = require('@aws-crypto/cache-material');
const { KeyringNode } = require('@aws-crypto/client-node');
const keyring = new KeyringNode({
generatorKeyId: 'arn:aws:kms:us-west-2:123456789012:key/abcd-1234-efgh-5678',
keyIds: ['arn:aws:kms:us-west-2:123456789012:key/abcd-1234-efgh-5678']
});
const cache = new NodeCachingMaterialsManager({
backingMaterials: keyring,
maxAge: 300000, // 5 minutes
maxBytesEncrypted: 1000000, // 1MB
maxMessagesEncrypted: 1000
});