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
});
withSku
Sets the SKU properties for the Redis Cache.
redisBuilder.withSku({
name: 'Premium',
family: 'P',
capacity: 1,
});
withNetwork
Sets 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'],
});
buildRedis
Creates the Redis Cache instance with the specified configurations.
This method is called internally by the build
method and is not typically called directly.
buildNetwork
Configures 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.
buildSecrets
Stores Redis Cache connection details in Azure Key Vault.
This method is called internally by the build
method and is not typically called directly.
build
Builds 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.