heroku
Version:
CLI to interact with Heroku
41 lines (39 loc) • 2.15 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = require("@heroku-cli/command");
const core_1 = require("@oclif/core");
const api_1 = require("../../lib/redis/api");
class MaxMemory extends command_1.Command {
async run() {
const { flags, args } = await this.parse(MaxMemory);
const { app, policy } = flags;
const { database } = args;
const addon = await (0, api_1.default)(app, database, false, this.heroku).getRedisAddon();
const { body: config } = await (0, api_1.default)(app, database, false, this.heroku)
.request(`/redis/v0/databases/${addon.name}/config`, 'PATCH', { maxmemory_policy: policy });
const configVars = addon.config_vars || [];
core_1.ux.log(`Maxmemory policy for ${addon.name} (${configVars.join(', ')}) set to ${config.maxmemory_policy.value}.`);
core_1.ux.log(`${config.maxmemory_policy.value} ${config.maxmemory_policy.values[config.maxmemory_policy.value]}.`);
}
}
exports.default = MaxMemory;
MaxMemory.topic = 'redis';
MaxMemory.description = `set the key eviction policy when instances reach their storage limit
Available policies for key eviction include:
noeviction
allkeys-lfu
volatile-lfu
allkeys-lru
volatile-lru
allkeys-random
volatile-random
volatile-ttl
`;
MaxMemory.flags = {
app: command_1.flags.app({ required: true }),
policy: command_1.flags.string({ char: 'p', description: 'set policy name', required: true }),
remote: command_1.flags.remote(),
};
MaxMemory.args = {
database: core_1.Args.string({ description: 'name of the Key-Value Store database. If omitted, it defaults to the primary database associated with the app.' }),
};