arash16 / nuxt-ssr-cache

Cache middleware for nuxt's SSR rendering.
MIT License
295 stars 64 forks source link

ttl in memcached #14

Open anzolo opened 5 years ago

anzolo commented 5 years ago

Hi! Thank you for awesome module!

I try to use memcached as a store. But I can't find a way to put ttl to cache options.

function renderSetCache(){ return renderRoute(route, context) .then(function(result) { if (!result.error) { cache.setAsync(cacheKey, serialize(result)); } return result; }); }

In your code from middleware.js you don't put options with ttl in set method of the cache.

node-cache-manager-memcached-store package wait for this signature:

/**

  • Set a value for a given key.
  • @method set
  • @param {String} key - The cache key
  • @param {String} value - The value to set
  • @param {Object} [options] - The options (optional)
  • @param {Object} options.ttl - The ttl value. Default is 2592000 seconds
  • @param {Function} [cb] - A callback that returns a potential error, otherwise null */ MemcachedClient.prototype.set = function (key, value, options, cb) { var opt = { ttl: 2592000 }

Can you fix this or better will be to make a pull request?