karlseguin / the-little-redis-book

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(error) ERR Operation against a key holding the wrong kind of value

sillygwailo opened this issue · comments

In the data structures chapter, you get us to create a couple of sets, friends:leto and friends:duncan. In the next section, you get us to add scores to the set items, using zadd friends:leto 100 ghanima etc. I get the following error, though:

(error) ERR Operation against a key holding the wrong kind of value

Are sets and sorted sets completely different data structures? I was able to get through the chapter by choosing a different name for the sorted lists (zadd sfriends etc.) and couldn't find anything online to support the assertion that sets and sorted sets are two distinct data types.

I changed the key to friends:duncan. I agree using the same key is a mistake/wrong.

They are two distinct types. The chapter starts off with "The last and most powerful data structure are sorted sets. If hashes are like strings but with fields, then sorted sets are like sets but with a score.."....My initial instinct is that that's pretty clear...do you think changing the key is enough, or do you think I should look at further emphasizing that it's a different data type?

I think you should look at further emphasizing the difference in data types. Sort of too bad, because I think the Redis project chose names poorly. Set and Sorted Set sound like one is an extension of the other, and also implies some compatibility. Anyway, I think it would be clearer if you used a different key and data, since the similarities between friends:leto and friends:duncan imply that the data types are similar. (I know, completely different keys as far as Redis is concerned. But the same 'prefix' makes the implication.) So maybe something else, like ranking of people within the House of Atreides (or Harkonnen if rankings are more obvious in the series) for example.