UNPKG

strapi-pfapi

Version:

a strapi plugin library uses local and redis caches to achieve single digit milliseconds on average api response time.

18 lines (14 loc) 428 B
'use strict'; module.exports.get_redis_key = (prefix, key) => { if (!prefix) prefix = ''; return `${prefix}::{${key}}`; }; module.exports.get_prefix_key = (redis_key) => { const parts = redis_key.split('::'); if (parts.length !== 2) { throw new Error('invalid redis_key format'); } const prefix = parts[0]; const key = parts[1].substr(1, parts[1].length - 2); return {prefix, key}; };