rueidislock should use CoreClient instead of Client
Gobd opened this issue · comments
Brian Kemper commented
This make the below possible which I think works and would be nice. The Locker can share a client already created:
locker, _ := rueidislock.NewLocker(rueidislock.LockerOption{
ClientBuilder: func(rueidis.ClientOption) (rueidis.CoreClient, error) {
dc, _ := c.Redis.Dedicate()
return dc, err
},
})
Rueian commented
Hi @Gobd,
Unfortunately, rueidislock requires some special configurations in rueidis.ClientOption
to work correctly. When using the ClientBuilder
, you must respect the rueidis.ClientOption
passed in to build a rueidis.Client.
Generally, I don't recommend sharing rueidislock's client with other usages, but here is what you can do:
locker, _ := rueidislock.NewLocker(rueidislock.LockerOption{...})
client := locker.Client()
client.Do(ctx, client.B().Get().Key(..).Build()) // share the client created by rueidislock
Brian Kemper commented
Thanks for the response! I'll keep my code the way I have it. The lock is working great :)