RedisCacheBuilder Class OverviewThe RedisCacheBuilder class is designed to build and configure an Azure Redis Cache instance with specific configurations such as SKU, network settings, and secrets management.
Initializes the RedisCacheBuilder with the provided arguments and sets the instance name.
const redisBuilder = new RedisCacheBuilder({
name: 'myRedisCache',
group: { resourceGroupName: 'myResourceGroup' },
// other necessary arguments
});
withSkuSets the SKU properties for the Redis Cache.
redisBuilder.withSku({
name: 'Premium',
family: 'P',
capacity: 1,
});
withNetworkSets the network properties for the Redis Cache, including subnet ID and private link settings.
redisBuilder.withNetwork({
subnetId: 'subnet-id',
privateLink: {
// private link properties
},
ipAddresses: ['192.168.1.1', '192.168.1.2'],
});
buildRedisCreates the Redis Cache instance with the specified configurations.
This method is called internally by the build method and is not typically called directly.
buildNetworkConfigures network settings for the Redis Cache, including firewall rules and private link.
This method is called internally by the build method and is not typically called directly.
buildSecretsStores Redis Cache connection details in Azure Key Vault.
This method is called internally by the build method and is not typically called directly.
buildBuilds the Redis Cache instance, configures network settings, and stores secrets.
const resourceInfo = redisBuilder.build();
console.log(resourceInfo);
Here is a full example demonstrating how to use the RedisCacheBuilder class:
import RedisCacheBuilder from './Builder/RedisCacheBuilder';
import { RedisCacheBuilderArgs } from './types';
const args: RedisCacheBuilderArgs = {
name: 'myRedisCache',
group: { resourceGroupName: 'myResourceGroup' },
// other necessary arguments
};
const redisBuilder = new RedisCacheBuilder(args);
redisBuilder
.withSku({
name: 'Premium',
family: 'P',
capacity: 1,
})
.withNetwork({
subnetId: 'subnet-id',
privateLink: {
// private link properties
},
ipAddresses: ['192.168.1.1', '192.168.1.2'],
});
const resourceInfo = redisBuilder.build();
console.log(resourceInfo);
This guideline should help developers understand and reuse the methods in the RedisCacheBuilder class effectively.