* Create a new Index object.
()
| 36 | * Create a new Index object. |
| 37 | */ |
| 38 | constructor() { |
| 39 | // Connect to a redis server. |
| 40 | const TOKEN_DB = 0; |
| 41 | const DOCS_DB = 1; |
| 42 | const PORT = process.env.REDIS_PORT || '6379'; |
| 43 | const HOST = process.env.REDIS_HOST || '127.0.0.1'; |
| 44 | |
| 45 | this.tokenClient = redis |
| 46 | .createClient({url: `redis://${HOST}:${PORT}`, db: TOKEN_DB}) |
| 47 | .on('error', err => { |
| 48 | console.error('ERR:REDIS: ' + err); |
| 49 | throw err; |
| 50 | }); |
| 51 | this.docsClient = redis |
| 52 | .createClient({url: `redis://${HOST}:${PORT}`, db: DOCS_DB}) |
| 53 | .on('error', err => { |
| 54 | console.error('ERR:REDIS: ' + err); |
| 55 | throw err; |
| 56 | }); |
| 57 | |
| 58 | (async () => { |
| 59 | await this.tokenClient.connect(); |
| 60 | await this.docsClient.connect(); |
| 61 | })(); |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Close all active redis server connections. |
nothing calls this directly
no outgoing calls
no test coverage detected