UNPKG

image-utility-library

Version:

A Node.js library for compressing, resizing, cropping, and applying effects to images.

23 lines (19 loc) 605 B
import NodeCache from 'node-cache'; const cache = new NodeCache({ stdTTL: 300 }); // Cache TTL: 5 minutes /** * Cache the processed image. * @param {String} key - Unique key for the cache. * @param {Buffer} buffer - Image buffer to cache. */ const cacheImage = (key, buffer) => { cache.set(key, buffer); }; /** * Retrieve an image from the cache. * @param {String} key - Key for the cached image. * @returns {Buffer|null} - Cached image buffer or null if not found. */ const getCachedImage = (key) => { return cache.get(key); }; export { cacheImage, getCachedImage };