-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add config option to not connect in the constructor #350
Comments
Seems |
Does it work in Cluster mode as well? I want to do something like this: var redis = new Redis.Cluster();
// then sometime later
redis.connect().then(() => ...) |
hmm...It doesn't work in cluster mode. What's your use case? |
I just want to have the redis instance created in the constructor of my own class, and then make sure it connects before using it. We can just wrap this line: https://github.com/luin/ioredis/blob/master/lib/cluster/index.js#L83 |
Yeah, should be pretty similar to the standalone version: https://github.com/luin/ioredis/blob/master/lib/redis.js#L126-L131 |
For me it also looks very strange that instantiation does some connections. mongoose.connect('mongodb://localhost/myapp');
var MyModel = mongoose.model('Test', new Schema({ name: String }));
// Works
MyModel.findOne(function(error, result) { /* ... */ }); Yes, I can use |
Hi,
Can we add a config option to the constructor so that it will not try to connect until manually calling
.connect()
?The text was updated successfully, but these errors were encountered: