"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CacheManagerOptions = void 0;
const config_1 = require("@nestjs/config");
const cache_manager_redis_store_1 = require("cache-manager-redis-store");
const environment_helper_1 = require("../helpers/environment.helper");
exports.CacheManagerOptions = {
    isGlobal: true,
    imports: [config_1.ConfigModule],
    useFactory: async (configService) => {
        if (!(0, environment_helper_1.isRedisConfigured)(configService)) {
            return {
                ttl: 0
            };
        }
        const store = await createRedisStore(configService);
        return {
            store: () => store,
        };
    },
    inject: [config_1.ConfigService],
};
async function createRedisStore(configService) {
    return await (0, cache_manager_redis_store_1.redisStore)({
        socket: {
            host: configService.get('REDIS_HOST'),
            port: parseInt(configService.get('REDIS_PORT')),
        },
    });
}
//# sourceMappingURL=cache.options.js.map