Skip to content
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

Redis driver is coded in way that it's lazyConnect #469

Open
olivbau opened this issue Jul 30, 2024 · 0 comments
Open

Redis driver is coded in way that it's lazyConnect #469

olivbau opened this issue Jul 30, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@olivbau
Copy link

olivbau commented Jul 30, 2024

Environment

Unstorage v1.10.2

Reproduction

  1. Create a Driver or Storage object without manually calling getRedisClient().
  2. Attempt to call setItem or getItem.

Describe the bug

The Redis instance is initialized only when the getRedisClient() function is called. However, getRedisClient() is never invoked during the creation of the Driver or the Storage objects. As a result, the first call to getRedisClient() occurs only when setItem or getItem is called.

This causes an issue where the Redis instance is created and attempts to get or set an item, but the ioredis instance has not yet established a connection to the Redis server.

Expected Behavior

The Redis instance should be initialized and connected to the Redis server before any get or set operations are performed.

Actual Behavior

The Redis instance is created at the time of the first setItem or getItem call, and the ioredis instance is not yet connected.

Possible Solution

Ensure that the getRedisClient() function is called after beeing defined to establish a connection to the Redis server before any operations are performed.
From what I can see, it seems to be same for Mongodb

Additional context

No response

Logs

No response

@olivbau olivbau added the bug Something isn't working label Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant