UNPKG

@amirmarmul/waba-common

Version:

![GitHub release](https://img.shields.io/github/v/release/amirmarmul/waba-common?style=flat-square)

17 lines (16 loc) 503 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.cache = void 0; const Container_1 = require("../../core/infrastructure/Container"); async function cache(key, callback, ttl = 30) { const cache = Container_1.Container.get('cacheService'); const value = await cache.get(key); if (value) { return value; } return callback().then(async (data) => { await cache.set(key, data, ttl); return data; }); } exports.cache = cache;