mediocregopher / radix.v2

Redis client for Go
http://godoc.org/github.com/mediocregopher/radix.v2
MIT License
433 stars 92 forks source link

DEL always returns "wrong type" #23

Closed milgner closed 8 years ago

milgner commented 8 years ago

When I run a DEL command, it will always return "wrong type", even though the key existed beforehand and the deletion was executed correctly. (I'm using redis-cli to check it) Unfortunately that renders me unable to use it in a MULTI-enabled pipeline because it makes the final EXEC fail with the same error.

mediocregopher commented 8 years ago

Hi milgner! Can you provide an example of some code that does this? Also, can you confirm you're not using *redis.Client in a multi-threaded way? If so you should check out the pool package.

milgner commented 8 years ago

Thanks for the quick feedback. As a matter of fact I am using the pool package. I cut everything else from my original code and created a SSCE for the issue.

Its output:

2016/03/05 23:28:02 Reading from Redis key foo_key
2016/03/05 23:28:02 Could not delete data:  wrong type
2016/03/05 23:28:02 Read data: bar_value
2016/03/05 23:28:02 All is well that ends well

Everything else works really great, so I'll take this opportunity to thank you for a great library! :)

mediocregopher commented 8 years ago

Ah, so the issue is that you're calling Str on the DEL return, but DEL returns an integer reply. Try calling Int or Int64, or just check the Err field directly if you don't really care about the return value.

Also, and this is irrelevant to your question but I just wanted to clear up any confusion you might have:

return "", errors.New("Redis connection pool exhausted")

When the pool is out of connections it will make more on the fly. An error from the pool indicates that one of the connections it's making on the fly wasn't able to made for some reason. Again, not relevant to this :P

On Sat, Mar 5, 2016 at 3:31 PM Marcus Ilgner notifications@github.com wrote:

Thanks for the quick feedback. As a matter of fact I am using the pool package. I cut everything else from my original code and created a SSCE https://gist.github.com/milgner/29a2231ef3d3c016b616 for the issue.

Its output:

2016/03/05 23:28:02 Reading from Redis key foo_key 2016/03/05 23:28:02 Could not delete data: wrong type 2016/03/05 23:28:02 Read data: bar_value 2016/03/05 23:28:02 All is well that ends well

Everything else works really great, so I'll take this opportunity to thank you for a great library! :)

— Reply to this email directly or view it on GitHub https://github.com/mediocregopher/radix.v2/issues/23#issuecomment-192752962 .

milgner commented 8 years ago

Ah, now I understand! Facepalm... Didn't see the forest through the trees. Many thanks for clearing that up!