redis.js 509 B

1234567891011121314151617181920212223242526272829
  1. 'use strict'
  2. /* global wiki */
  3. const Redis = require('ioredis')
  4. const { isPlainObject } = require('lodash')
  5. /**
  6. * Redis module
  7. *
  8. * @return {Object} Redis client wrapper instance
  9. */
  10. module.exports = {
  11. /**
  12. * Initialize Redis client
  13. *
  14. * @return {Object} Redis client instance
  15. */
  16. init() {
  17. if (isPlainObject(wiki.config.redis)) {
  18. return new Redis(wiki.config.redis)
  19. } else {
  20. wiki.logger.error('Invalid Redis configuration!')
  21. process.exit(1)
  22. }
  23. }
  24. }