INNER CODE UNIT · JavaScript

cleanKey

leemonade/leemons · packages/leemons-cache/src/types/node/index.js:10

function cleanKey(key, pluginName) {
  return key.replace(new RegExp(`^${pluginName}\\.`), '');
}

module.exports = function nodeCache() {
  const cache = new NodeCache();
  return (pluginName) => ({
    get: async (key) => cache.get(generateKey(key, pluginName)),
    has: async (key) => cache.has(generateKey(key, pluginName)),
    set: async (key, value, ttl) => cache.set(generateKey(key, pluginName), value, ttl),
    delete: async (key) => {
      if (Array.isArray(key)) {
        throw new Error('Delete only supports single key deletions');
      }
      return cache.del(generateKey(key, pluginName));
    },

    getMany: async (keys) =>

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…