rest-envelop
Version:
Wrapper for working with REST API using well-known axios and native fetch modules, with pluggable caching, retry with backoff, and TypeScript typings
9 lines (6 loc) • 365 B
JavaScript
const { Redis, Memcached } = require('cache-envelop');
const { REDIS_CACHE_SERVICE, MEMCACHED_CACHE_SERVICE } = require('../constants');
module.exports = ({ redis, memcached: { servers, options } = {} }) => ({
redis: () => new Redis(redis).client,
memcached: () => new Memcached(servers, options),
}[redis ? REDIS_CACHE_SERVICE : MEMCACHED_CACHE_SERVICE]());