UNPKG

node-cache-redis

Version:

Simplistic node redis cache ready can scale with generic-pool support

20 lines (19 loc) 813 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var InvalidTtlError_1 = __importDefault(require("../error/InvalidTtlError")); exports.default = (function ( // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any ttlInSeconds, defaultTtlInS) { // validate only if ttl is given if (typeof ttlInSeconds === 'undefined' || ttlInSeconds === null) { return defaultTtlInS; } var ttl = parseInt(ttlInSeconds, 10); if (Number.isNaN(ttl) || ttl <= 0) { throw new InvalidTtlError_1.default('ttlInSeconds should be a non-zero integer'); } return ttl; });