Closed xs-411 closed 2 years ago
Your code should work. However, singleton is an anti-pattern. Avoid using it, if you can.
In your case, why not pass the shared_ptr<Redis>
to User
? If some other classes also want to use Redis
, copy the shared_ptr to it as a data member.
Regards
Thank you. I understand。
Here's my example. Is there a better way?