You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
617 B

  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. let red = new Redis(wiki.config.redis)
  19. red.on('ready', () => {
  20. wiki.logger.info('Redis connection: OK')
  21. })
  22. return red
  23. } else {
  24. wiki.logger.error('Invalid Redis configuration!')
  25. process.exit(1)
  26. }
  27. }
  28. }