Updating mock redis to only import if it is needed.
This commit is contained in:
parent
91f760d7c4
commit
ddeb25b68d
|
@ -1,7 +1,11 @@
|
|||
import env from "../environment"
|
||||
import Redis from "ioredis"
|
||||
// mock-redis doesn't have any typing
|
||||
let MockRedis: any | undefined
|
||||
if (env.MOCK_REDIS) {
|
||||
// ioredis mock is all in memory
|
||||
const MockRedis = require("ioredis-mock")
|
||||
MockRedis = require("ioredis-mock")
|
||||
}
|
||||
import {
|
||||
addDbPrefix,
|
||||
removeDbPrefix,
|
||||
|
@ -56,7 +60,7 @@ function connectionError(
|
|||
* will return the ioredis client which will be ready to use.
|
||||
*/
|
||||
function init(selectDb = DEFAULT_SELECT_DB) {
|
||||
const RedisCore = env.MOCK_REDIS ? MockRedis : Redis
|
||||
const RedisCore = env.MOCK_REDIS && MockRedis ? MockRedis : Redis
|
||||
let timeout: NodeJS.Timeout
|
||||
CLOSED = false
|
||||
let client = pickClient(selectDb)
|
||||
|
|
Loading…
Reference in New Issue