arash16 / nuxt-ssr-cache

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

about redisCache #3

Closed falstack closed 5 years ago

falstack commented 5 years ago

sorry i don't know why use redis client and quit:

function redisCache(config) {
  if (config && Array.isArray(config.configure)) {
    const redis = require('redis')
    const client = redis.createClient(config.client)
    config.configure.forEach(function(options) {
      client.config('set', ...options, function(err, result) {
        if (err || result !== 'ok') {
          console.error(err)
        }
      })
    })
    client.quit()
  }

  return cacheManager.caching({
    store: require('cache-manager-redis'),
    retry_strategy() {
      return undefined
    },
    ...config
  })
}

why don't:

function redisCache(config) {
  return cacheManager.caching({
    store: require('cache-manager-redis'),
    retry_strategy() {
      return undefined
    },
    ...config
  })
}

and maybe we don't need multi-cache?

--- update

and why need serialize cache string?

arash16 commented 5 years ago

Configure is used to execute some configuration commands on redis instance, so that when it's memory is full, it knows which keys to evict (see sample usage).

If you don't need multi-cache you can simply configure it that.

About serialization, the object that is returned from nuxt contains some fields that can't be stringified easily.

falstack commented 5 years ago

Thanks