constructor(options = {}) { const { port, host, client, setex, password, database, prefix } = options; if ('string' === typeof options) { options = parse(options); } if ('function' === typeof setex) { this.client = options; } else if (client) { this.client = client; } else if (!port && !host) { this.client = new redis.createClient(); } else { this.client = new redis.createClient(port, host, { ...options, prefix: null }); } if (password) { this.client.auth(password, err => { if (err) throw err; }); } if (database) { this.client.select(database, err => { if (err) throw err; }); } this.prefix = prefix || 'cacheman:'; }