How to use the global-cache.set function in global-cache

To help you get started, we’ve selected a few global-cache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github unihooks / unihooks / test / useGlobalCache.js View on Github external
t('useGlobalCache: must be writable', async t => {
  globalCache.set('x', 1)

  let log = []

  enhook(() => {
    let [x, setX] = useGlobalCache('x')
    log.push(x)
    setX(2)
  })()

  t.deepEqual(log, [1])
  await tick(3)
  t.deepEqual(log, [1, 2])

  globalCache.delete('x')
  t.end()
})
github unihooks / unihooks / test / useGlobalCache.js View on Github external
t('useGlobalCache: basic', async t => {
  globalCache.set('count', 0)
  let log = []
  let f = enhook(() => {
    let [count, setCount] = useGlobalCache('count')
    log.push(count)
    useEffect(() => {
      setCount(1)
    }, [])
  })
  f()
  t.deepEqual(log, [0])
  await frame(4)
  t.deepEqual(log, [0, 1])

  globalCache.delete('count')
  t.end()
})
github jackdh / RasaTalk / server / mongo / controllers / utils / cache.js View on Github external
function set(key, value) {
  return cache.set(key, value);
}
github jackdh / RasaTalk / server / mongo / controllers / utils / cache.js View on Github external
return DialogSchema.find().then(model => {
          debug('Email Talk');
          const data = { emails: {}, flow: Convert.convert(model), map: model };
          cache.set('dialogCache', {
            data,
            time: moment.now(),
          });
          return resolve(
            `Updated: ${stAmount} - Dialog Amount: ${
              Object.keys(data.flow).length
            }`,
          );
        });
      }

global-cache

Sometimes you have to do horrible things, like use the global object to share a singleton. Abstract that away, with this!

MIT
Latest version published 7 years ago

Package Health Score

53 / 100
Full package analysis