1.0.7 • Published 7 years ago

think-ioredis v1.0.7

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

think-ioredis

Use ioredis for thinkjs session,cache Wo had test using for session and cache

Features

  • defined prefix for session.

Install

npm install think-ioredis

How to use

  • import Adapter
import ioredisAdapter from 'think-ioredis'
think.adapter('socket', 'ioredis', ioredisAdapter.Socket)
think.adapter('cache', 'ioredis', ioredisAdapter.Cache)
think.adapter('session', 'ioredis', ioredisAdapter.Session)
  • defined config: common/config/ioredis.js
'use strict'

/**
 * redis configs
 * more  than one nodes,wo will connection with Redis Cluster
 */
export default {
  nodes: [
    {
      host: 'localhost',
      port: 6379
    },
  // {
  //   host: '10.21.10.101',
  //   port: 6370
  // }
  ],
  password: ''
  // ... other config
}
  • Cache config
  type: 'ioredis', // config ioredis type
  timeout: 3600, 
  adapter: { 
    ioredis: {
      prefix: 'mydmpweb:cache:'
    }
  }
  • Session config
'use strict'

/**
 * session configs
 */
export default {
  name: 'thinkjs_',
  type: 'ioredis',
  secret: '6T3fdfert34&3e3dedtrre#',
  timeout: 3600,
  cookie: { // cookie options
    length: 32,
    httponly: true
  },
  adapter: {
    ioredis: {
      prefix: 'mydmpweb:session:'
    }
  }
}

Usage is the same as official adapter

LICENSE

MIT

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago