How to use the memory-cache.put function in memory-cache

To help you get started, we’ve selected a few memory-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 ovh-ux / ovh-chatbot / config / middlewares / verifyOvhUser.js View on Github external
request(options, (err, resp, body) => {
        if (err || resp.statusCode >= 400) {
          return reject(resp && resp.statusCode ? { statusCode: resp.statusCode, data: body } : { statusCode: 500, data: err });
        }
        cache.put(req.cookies.SESSION, JSON.stringify(body), config.web.cacheTime); // Cache the response for the next 2000 ms
        return resolve(body);
      });
    })
github Mailtrain-org / mailtrain / routes / subscription.js View on Github external
res.render('subscription/widget-subscribe', data, (err, html) => {
                        if (err) {
                            return sendError(err);
                        }

                        let response = {
                            data: {
                                title: data.title,
                                cid: data.cid,
                                html
                            }
                        };

                        cache.put(req.path, response, 30000); // ms
                        res.status(200).json(response);
                    });
                });
github alexose / sieve / lib / helpers.js View on Github external
toCache : function(entry, data, all){

    // TODO: Respect cache headers from response
    var time = (entry.cache || 60 * 60 * 24) * 1000
      , max = 2147483647  // http://stackoverflow.com/questions/3468607
      , key = this.hash(entry, all);

    time = time > max ? max : time;

    cache.put(key, data, time);

    return true;
  },
  hash : function(){
github trulia / webpagetest-charts-api / routes / tests.js View on Github external
function setCache(req, data) {
  const key = cacheKey(req);

  debug("setting cache key: " + key);
  debug(data);

  return cache.put(key, data, 1000 * (60 * 60));
}
github DataFire / DataFire / src / lib / project-server.js View on Github external
res.end = (body, encoding) => {
              let toCache = {body, headers:res.header()._headers};
              memCache.put(req.cacheKey, toCache, cacheTime)
              return origEnd(body, encoding);
            }
            next();
github pterodactyl / daemon / src / helpers / config.js View on Github external
constructor() {
        if (_.isNull(Cache.get('config'))) {
            Cache.put('config', this.raw());
        }
    }
github yodlr / CoreGI / lib / fleetctl.js View on Github external
fleet.fc.list_machines(function(err, machines){
    if(err) {
      log.error({err: err}, 'Error - Fleetctl: listMachines');
      cache.del('machines');
    }
    else if(machines) {
      log.debug({data: machines}, 'Fleetctl: listMachines');
      cache.put('machines', machines);
    }
    callback(null);
  });
};
github formio / formio / src / resources / LegacyValidator.js View on Github external
.then(body => {
            if (!body || !body.length) {
              const error = {
                message: `"${value}" for "${component.label || component.key}" is not a valid selection.`,
                path: state.path,
                type: 'any.select'
              };
              cache.put(cacheKey, error, cacheTime);
              return resolve(error);
            }

            cache.put(cacheKey, true, cacheTime);
            return resolve(null);
          })
          .catch(result => {
github danfang / me-api / lib / middleware / googleplus.js View on Github external
gplus.activities.list(opts, function(err, posts) {
          if (err) return handleError(err, res);
          var data = posts;
          cache.put(cacheKey, data, DEFAULT_CACHE_MSEC);
          res.json(data);
        });
      }

memory-cache

A simple in-memory cache. put(), get() and del()

BSD-2-Clause
Latest version published 7 years ago

Package Health Score

68 / 100
Full package analysis

Popular memory-cache functions